- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
scala.tools.nsc.FatalError: object List does not have a member apply
Fri, 2011-12-16, 04:15
*Sometimes* I'm getting this FatalError. It is undetermininstic, meaning
that I run tests with sbt and the Error may or may not come without
changing the sources or anything else. parallelExecution in Test is off.
Stacktrace:
http://pastebin.com/PhYEehGM
At line 57 of the trace you see
pluginTestFramework.CompilerWithUserPlugins$class.compileCode(CompilerWithUserPlugins.scala:56)
line 54-56 of my code are
val compiler: Global = global
val run/*: compiler.type#Run*/ = new compiler.Run()
run compileSources(sources.toList)
Any ideas?
Fri, 2011-12-16, 10:41
#2
Re: scala.tools.nsc.FatalError: object List does not have a memb
> That looks fine (instantiating a Run calls definitions.init), who else
> has access to val compiler?
I have different instances of Global, e.g. my 'preprocessor' compiler
plugin has 2 global instances for rangepositions and to compile
preprocessor code. I wasn't aware I have to restrict access to compiler.
> It sounds like using a global before it is fully initialized. You
> can't even look at it funny until definitions.init is complete. I
> hypothesize that you are looking at it funny somewhere.
How do I initialize global? Calling definitions.init results directly in
an exception:
val compiler = {
val g = new Global(settings, null)
g.definitions.init
g
}
java.lang.AssertionError: assertion failed
at scala.Predef$.assert(Predef.scala:89)
at
scala.tools.nsc.symtab.Symbols$TypeHistory.(Symbols.scala:2190)
at
scala.tools.nsc.symtab.Symbols$Symbol.info_$eq(Symbols.scala:747)
at
scala.tools.nsc.symtab.Symbols$TypeSymbol.info_$eq(Symbols.scala:1945)
(...)
How do I ensure definitions.init is complete or how do I look at global
in a non-funny manner?
Wed, 2011-12-21, 21:31
#3
Re: Re: scala.tools.nsc.FatalError: object List does not have a
On Fri, Dec 16, 2011 at 1:32 AM, Stefan Kuhn <qn.666@gmx.net> wrote:
That looks fine (instantiating a Run calls definitions.init), who else
has access to val compiler?
How do I initialize global?
You instantiate a Run, that's why I said this looks fine and surmised that the problem is elsewhere, e.g. you have concurrent access to the global taking place which you're not showing.
Here's a snippet from the test rig which has run about seventy bazillion times without ever showing the behavior you're describing.
def compile(args: String*) = { val settings = newSettings((CommandLineParser tokenize extraSettings) ++ args.toList) val global = new Global(settings) new global.Run compileSources List(new BatchSourceFile("<partest>", code)) !global.reporter.hasErrors }
On Thu, Dec 15, 2011 at 7:15 PM, Stefan Kuhn wrote:
> *Sometimes* I'm getting this FatalError. It is undetermininstic, meaning
> that I run tests with sbt and the Error may or may not come without changing
> the sources or anything else. parallelExecution in Test is off.
It sounds like using a global before it is fully initialized. You
can't even look at it funny until definitions.init is complete. I
hypothesize that you are looking at it funny somewhere.
> line 54-56 of my code are
> val compiler: Global = global
> val run/*: compiler.type#Run*/ = new compiler.Run()
> run compileSources(sources.toList)
That looks fine (instantiating a Run calls definitions.init), who else
has access to val compiler?