scala.tools.nsc.FatalError: object List does not have a member apply

50 views
Skip to first unread message

Stefan Kuhn

unread,
Dec 15, 2011, 10:15:11 PM12/15/11
to scala-i...@googlegroups.com
*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?

Paul Phillips

unread,
Dec 15, 2011, 10:59:04 PM12/15/11
to scala-i...@googlegroups.com
On Thu, Dec 15, 2011 at 7:15 PM, Stefan Kuhn <qn....@gmx.net> 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?

Stefan Kuhn

unread,
Dec 16, 2011, 4:32:21 AM12/16/11
to scala-i...@googlegroups.com
> 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.<init>(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?


Paul Phillips

unread,
Dec 21, 2011, 3:19:00 PM12/21/11
to scala-i...@googlegroups.com
On Fri, Dec 16, 2011 at 1:32 AM, Stefan Kuhn <qn....@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
  }

Reply all
Reply to author
Forward
0 new messages