I have a Scala 2.9 compiler plugin (source code) and works just fine in 2.9 but does not even compile with 2.10. There are dozens (maybe 100+) of errors all of the same kind such as:
[scalac] C:\***.scala:31: error: illegal cyclic reference involving class Global
[scalac] val fileSeparator = System.getProperty("file.separator");
[scalac] ^
... that eventually terminate with:
[scalac] scala.reflect.internal.Types$TypeError: illegal cyclic reference involving class Global
[scalac] at scala.reflect.internal.Types$class.defineBaseClassesOfCompoundType(Types.scala:1731)
[scalac] at scala.reflect.internal.SymbolTable.defineBaseClassesOfCompoundType(SymbolTable.scala:12)
[scalac] at scala.reflect.internal.Types$CompoundType.baseClasses(Types.scala:1581)
[scalac] at scala.reflect.internal.Types$TypeRef.baseClasses(Types.scala:2369)
[scalac] at scala.reflect.internal.Types$SimpleTypeProxy$class.baseClasses(Types.scala:248)
[scalac] at scala.reflect.internal.Types$SingletonType.baseClasses(Types.scala:1292)
[scalac] at scala.reflect.internal.Types$Type.findMembers(Types.scala:1058)
[scalac] at scala.reflect.internal.Types$Type.membersBasedOnFlags(Types.scala:683)
[scalac] at scala.reflect.internal.Types$Type.implicitMembers(Types.scala:637)
[scalac] at scala.tools.nsc.typechecker.Contexts$Context.collect$1(Contexts.scala:630)
[scalac] at scala.tools.nsc.typechecker.Contexts$Context.collectImplicitImports(Contexts.scala:642)
[scalac] at scala.tools.nsc.typechecker.Contexts$Context.implicitss(Contexts.scala:670)
[scalac] at scala.tools.nsc.typechecker.Contexts$Context.implicitss(Contexts.scala:675)
[scalac] at scala.tools.nsc.typechecker.Contexts$Context.implicitss(Contexts.scala:675)
[scalac] at scala.tools.nsc.typechecker.Contexts$Context.implicitss(Contexts.scala:675)
[scalac] at scala.tools.nsc.typechecker.Contexts$Context.implicitss(Contexts.scala:675)
[scalac] at scala.tools.nsc.typechecker.Contexts$Context.implicitss(Contexts.scala:675)
[scalac] at scala.tools.nsc.typechecker.Contexts$Context.implicitss(Contexts.scala:675)
[scalac] at scala.tools.nsc.typechecker.Contexts$Context.implicitss(Contexts.scala:675)
[scalac] at scala.tools.nsc.typechecker.Contexts$Context.implicitss(Contexts.scala:675)
[scalac] at scala.tools.nsc.typechecker.Contexts$Context.implicitss(Contexts.scala:675)
[scalac] at scala.tools.nsc.typechecker.Contexts$Context.implicitss(Contexts.scala:675)
[scalac] at scala.tools.nsc.typechecker.Implicits$ImplicitSearch.bestImplicit(Implicits.scala:1378)
[scalac] at scala.tools.nsc.typechecker.Implicits$class.inferImplicit(Implicits.scala:82)
[scalac] at scala.tools.nsc.Global$$anon$1.inferImplicit(Global.scala:490)
[scalac] at scala.tools.nsc.typechecker.Implicits$class.inferImplicit(Implicits.scala:37)
[scalac] at scala.tools.nsc.Global$$anon$1.inferImplicit(Global.scala:490)
[scalac] at scala.tools.nsc.typechecker.Typers$Typer.hasImport$1(Typers.scala:764)
[scalac] at scala.tools.nsc.typechecker.Typers$Typer.scala$tools$nsc$typechecker$Typers$Typer$$action$1(Typers.scala:766)
[scalac] at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$checkFeature$1.apply$mcV$sp(Typers.scala:788)
[scalac] at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3$$anonfun$apply$1.apply(Analyzer.scala:100)
[scalac] at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3$$anonfun$apply$1.apply(Analyzer.scala:100)
[scalac] at scala.collection.immutable.List.foreach(List.scala:309)
[scalac] at scala.collection.generic.TraversableForwarder$class.foreach(TraversableForwarder.scala:32)
[scalac] at scala.collection.mutable.ListBuffer.foreach(ListBuffer.scala:45)
[scalac] at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3.apply(Analyzer.scala:100)
[scalac] at scala.tools.nsc.Global$GlobalPhase.applyPhase(Global.scala:461)
[scalac] at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3$$anonfun$run$1.apply(Analyzer.scala:90)
[scalac] at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3$$anonfun$run$1.apply(Analyzer.scala:90)
[scalac] at scala.collection.Iterator$class.foreach(Iterator.scala:727)
[scalac] at scala.collection.AbstractIterator.foreach(Iterator.scala:1156)
[scalac] at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3.run(Analyzer.scala:90)
[scalac] at scala.tools.nsc.Global$Run.compileUnitsInternal(Global.scala:1574)
[scalac] at scala.tools.nsc.Global$Run.compileUnits(Global.scala:1548)
[scalac] at scala.tools.nsc.Global$Run.compileSources(Global.scala:1544)
[scalac] at scala.tools.nsc.Global$Run.compile(Global.scala:1654)
[scalac] at scala.tools.ant.Scalac.executeInternal(Scalac.scala:699)
[scalac] at scala.tools.ant.Scalac.execute(Scalac.scala:647)
...
I need some info or help as to what has changed in 2.10 or how to otherwise deal with this... I tried Googling around and looking in forums but found very little information on this subject.
Will be grateful for any help!
EDIT: Additional info. This is obviously using ant task (see stack trace). That task has been defined:
<taskdef resource="scala/tools/ant/antlib.xml">
<classpath>
<pathelement location=".../scala-library.jar" />
<pathelement location=".../scala-reflect.jar" />
<pathelement location=".../scala-compiler.jar" />
</classpath>
</taskdef>
EDIT 2: More additional info: I managed to get this plugin to compile (did not run it yet as other things failed) using command-line 2.10 compiler (remember - all is fine in 2.9 world) - ant-based build continues to fail the same way (bug?). I had to make two changes. First deals with varargs. There is a method such as:
def foo(arg: String*) { ... }
There is another method which is effectively a synonym for it ad was written in 2.9 Scala as:
def bar = foo _;
I had to change this to the following to get it to work:
def bar(arg: String*) = foo(arg: *);
Another dealt with 'hasAssignedAnnotations' not being present in ValOrDefDef.symbol any more (I just commented that out to get it to compile, not a real fix).
Again, does anyone know of a web site or a document out there that can help me with migration - i.e. what changed from 2.9 to 2.10 in terms that I need, including compiler plugins.
Thanks!
System
in the 2.10 compiler. In 2.10, you can also usesys.props("file.separator")
, might fix that error. – Galwegian