This page is no longer maintained — Please continue to the home page at www.scala-lang.org

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

3 replies
Stefan Kuhn
Joined: 2009-10-01,
User offline. Last seen 42 years 45 weeks ago.

*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?

extempore
Joined: 2008-12-17,
User offline. Last seen 35 weeks 3 days ago.
Re: scala.tools.nsc.FatalError: object List does not have a mem

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?

Stefan Kuhn
Joined: 2009-10-01,
User offline. Last seen 42 years 45 weeks ago.
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?

extempore
Joined: 2008-12-17,
User offline. Last seen 35 weeks 3 days ago.
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  }

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland