Type provider macro crashes presentation compiler
When I create a macro annotation the presentation compiler crashes.
The two source compiled in two separate projects, and the paradise plugin was added as compiler plugin
Details of both project
Kortefa.scala:
Test.scala
The project was compiled with gradle successful, and the output as expected was: "bar".
But the eclipse fails.
Output, that ide generates:
Can anybody help to make a workaround? Thanks!
The two source compiled in two separate projects, and the paradise plugin was added as compiler plugin
Details of both project
- Scala compiler: 2.11.2
- Paradise: 2.11.2-2.0.1
Kortefa.scala:
class Kortefa extends StaticAnnotation { def macroTransform(annottees: Any*) = macro Kortefa.impl } object Kortefa { def impl(c: Context)(annottees: c.Expr[Any]*) = { import c.universe._ val objectName = newTermName("GenKortefa") c.Expr(q"""object $objectName { def foo() = "bar"}""") } }
Test.scala
object Test extends App { import Kortefa._ @Kortefa object GenKortefa println(GenKortefa.foo) }
The project was compiled with gradle successful, and the output as expected was: "bar".
But the eclipse fails.
Output, that ide generates:
2014-08-18 14:08:07,597 ERROR [Scala Presentation Compiler [product]] - System.err - java.lang.AssertionError: assertion failed: object GenKortefa extends scala.AnyRef { def <init>() = { super.<init>(); () } } 2014-08-18 14:08:07,597 ERROR [Scala Presentation Compiler [product]] - System.err - at scala.tools.nsc.typechecker.Typers$Typer.typedModuleDef(Typers.scala:1772) 2014-08-18 14:08:07,597 ERROR [Scala Presentation Compiler [product]] - System.err - at scala.tools.nsc.typechecker.Typers$Typer.typedMemberDef$1(Typers.scala:5207) 2014-08-18 14:08:07,597 ERROR [Scala Presentation Compiler [product]] - System.err - at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5256) 2014-08-18 14:08:07,597 ERROR [Scala Presentation Compiler [product]] - System.err - at scala.tools.nsc.typechecker.Typers$Typer.runTyper$1(Typers.scala:5293) 2014-08-18 14:08:07,597 ERROR [Scala Presentation Compiler [product]] - System.err - at scala.tools.nsc.typechecker.Typers$Typer.scala$tools$nsc$typechecker$Typers$Typer$$typedInternal(Typers.scala:5320) 2014-08-18 14:08:07,597 ERROR [Scala Presentation Compiler [product]] - System.err - at scala.tools.nsc.typechecker.Typers$Typer.body$2(Typers.scala:5267) 2014-08-18 14:08:07,597 ERROR [Scala Presentation Compiler [product]] - System.err - at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5271) 2014-08-18 14:08:07,597 ERROR [Scala Presentation Compiler [product]] - System.err - at scala.tools.nsc.typechecker.Typers$Typer.typedArg(Typers.scala:3102) 2014-08-18 14:08:07,597 ERROR [Scala Presentation Compiler [product]] - System.err - at scala.tools.nsc.typechecker.PatternTypers$PatternTyper$class.typedArgWithFormal$1(PatternTypers.scala:112) 2014-08-18 14:08:07,597 ERROR [Scala Presentation Compiler [product]] - System.err - at scala.tools.nsc.typechecker.PatternTypers$PatternTyper$$anonfun$rest$1$1$$anonfun$apply$1.apply(PatternTypers.scala:116) 2014-08-18 14:08:07,597 ERROR [Scala Presentation Compiler [product]] - System.err - at scala.tools.nsc.typechecker.PatternTypers$PatternTyper$$anonfun$rest$1$1$$anonfun$apply$1.apply(PatternTypers.scala:116) 2014-08-18 14:08:07,597 ERROR [Scala Presentation Compiler [product]] - System.err - at scala.collection.immutable.List.map(List.scala:272) 2014-08-18 14:08:07,597 ERROR [Scala Presentation Compiler [product]] - System.err - at scala.tools.nsc.typechecker.PatternTypers$PatternTyper$$anonfun$rest$1$1.apply(PatternTypers.scala:116) 2014-08-18 14:08:07,597 ERROR [Scala Presentation Compiler [product]] - System.err - at scala.tools.nsc.typechecker.PatternTypers$PatternTyper$$anonfun$rest$1$1.apply(PatternTypers.scala:116) 2014-08-18 14:08:07,597 ERROR [Scala Presentation Compiler [product]] - System.err - at scala.tools.nsc.typechecker.Contexts$Context.withMode(Contexts.scala:374) 2014-08-18 14:08:07,597 ERROR [Scala Presentation Compiler [product]] - System.err - at scala.tools.nsc.typechecker.PatternTypers$PatternTyper$class.rest$1(PatternTypers.scala:116) 2014-08-18 14:08:07,597 ERROR [Scala Presentation Compiler [product]] - System.err - at scala.tools.nsc.typechecker.PatternTypers$PatternTyper$class.typedArgsForFormals(PatternTypers.scala:120) 2014-08-18 14:08:07,597 ERROR [Scala Presentation Compiler [product]] - System.err - at scala.tools.nsc.typechecker.Typers$Typer.typedArgsForFormals(Typers.scala:107) 2014-08-18 14:08:07,597 ERROR [Scala Presentation Compiler [product]] - System.err - at scala.tools.nsc.typechecker.Typers$Typer.scala$tools$nsc$typechecker$Typers$Typer$$handleMonomorphicCall$1(Typers.scala:3393) 2014-08-18 14:08:07,597 ERROR [Scala Presentation Compiler [product]] - System.err - at scala.tools.nsc.typechecker.Typers$Typer.doTypedApply(Typers.scala:3418) 2014-08-18 14:08:07,597 ERROR [Scala Presentation Compiler [product]] - System.err - at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$tryTypedApply$1$1.apply(Typers.scala:4402) 2014-08-18 14:08:07,597 ERROR [Scala Presentation Compiler [product]] - System.err - at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$tryTypedApply$1$1.apply(Typers.scala:4402) 2014-08-18 14:08:07,597 ERROR [Scala Presentation Compiler [product]] - System.err - at scala.tools.nsc.typechecker.Typers$Typer.silent(Typers.scala:696) 2014-08-18 14:08:07,597 ERROR [Scala Presentation Compiler [product]] - System.err - at scala.tools.nsc.typechecker.Typers$Typer.tryTypedApply$1(Typers.scala:4402) 2014-08-18 14:08:07,597 ERROR [Scala Presentation Compiler [product]] - System.err - at scala.tools.nsc.typechecker.Typers$Typer.normalTypedApply$1(Typers.scala:4447) 2014-08-18 14:08:07,597 ERROR [Scala Presentation Compiler [product]] - System.err - at scala.tools.nsc.typechecker.Typers$Typer.typedApply$1(Typers.scala:4482) 2014-08-18 14:08:07,597 ERROR [Scala Presentation Compiler [product]] - System.err - at scala.tools.nsc.typechecker.Typers$Typer.typedInAnyMode$1(Typers.scala:5240) 2014-08-18 14:08:07,597 ERROR [Scala Presentation Compiler [product]] - System.err - at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5257) 2014-08-18 14:08:07,597 ERROR [Scala Presentation Compiler [product]] - System.err - at scala.tools.nsc.typechecker.Typers$Typer.runTyper$1(Typers.scala:5293) 2014-08-18 14:08:07,597 ERROR [Scala Presentation Compiler [product]] - System.err - at scala.tools.nsc.typechecker.Typers$Typer.scala$tools$nsc$typechecker$Typers$Typer$$typedInternal(Typers.scala:5320) 2014-08-18 14:08:07,597 ERROR [Scala Presentation Compiler [product]] - System.err - at scala.tools.nsc.typechecker.Typers$Typer.body$2(Typers.scala:5267) 2014-08-18 14:08:07,597 ERROR [Scala Presentation Compiler [product]] - System.err - at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5271) 2014-08-18 14:08:07,597 ERROR [Scala Presentation Compiler [product]] - System.err - at scala.tools.nsc.typechecker.Typers$Typer.typedByValueExpr(Typers.scala:5349) 2014-08-18 14:08:07,597 ERROR [Scala Presentation Compiler [product]] - System.err - at scala.tools.nsc.typechecker.Typers$Typer.scala$tools$nsc$typechecker$Typers$Typer$$typedStat$1(Typers.scala:2985) 2014-08-18 14:08:07,597 ERROR [Scala Presentation Compiler [product]] - System.err - at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$61.apply(Typers.scala:3089) 2014-08-18 14:08:07,597 ERROR [Scala Presentation Compiler [product]] - System.err - at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$61.apply(Typers.scala:3089) 2014-08-18 14:08:07,597 ERROR [Scala Presentation Compiler [product]] - System.err - at scala.collection.immutable.List.loop$1(List.scala:172) 2014-08-18 14:08:07,597 ERROR [Scala Presentation Compiler [product]] - System.err - at scala.collection.immutable.List.mapConserve(List.scala:188) 2014-08-18 14:08:07,597 ERROR [Scala Presentation Compiler [product]] - System.err - at scala.tools.nsc.typechecker.Typers$Typer.typedStats(Typers.scala:3089) 2014-08-18 14:08:07,597 ERROR [Scala Presentation Compiler [product]] - System.err - at scala.tools.nsc.typechecker.Typers$Typer.typedTemplate(Typers.scala:1892) 2014-08-18 14:08:07,607 ERROR [Scala Presentation Compiler [product]] - System.err - at scala.tools.nsc.typechecker.Typers$Typer.typedModuleDef(Typers.scala:1779) 2014-08-18 14:08:07,607 ERROR [Scala Presentation Compiler [product]] - System.err - at scala.tools.nsc.typechecker.Typers$Typer.typedMemberDef$1(Typers.scala:5207) 2014-08-18 14:08:07,607 ERROR [Scala Presentation Compiler [product]] - System.err - at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5256) 2014-08-18 14:08:07,607 ERROR [Scala Presentation Compiler [product]] - System.err - at scala.tools.nsc.typechecker.Typers$Typer.runTyper$1(Typers.scala:5293) 2014-08-18 14:08:07,607 ERROR [Scala Presentation Compiler [product]] - System.err - at scala.tools.nsc.typechecker.Typers$Typer.scala$tools$nsc$typechecker$Typers$Typer$$typedInternal(Typers.scala:5320) 2014-08-18 14:08:07,607 ERROR [Scala Presentation Compiler [product]] - System.err - at scala.tools.nsc.typechecker.Typers$Typer.body$2(Typers.scala:5267) 2014-08-18 14:08:07,607 ERROR [Scala Presentation Compiler [product]] - System.err - at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5271) 2014-08-18 14:08:07,607 ERROR [Scala Presentation Compiler [product]] - System.err - at scala.tools.nsc.typechecker.Typers$Typer.typedByValueExpr(Typers.scala:5349) 2014-08-18 14:08:07,607 ERROR [Scala Presentation Compiler [product]] - System.err - at scala.tools.nsc.typechecker.Typers$Typer.scala$tools$nsc$typechecker$Typers$Typer$$typedStat$1(Typers.scala:2985) 2014-08-18 14:08:07,607 ERROR [Scala Presentation Compiler [product]] - System.err - at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$61.apply(Typers.scala:3089) 2014-08-18 14:08:07,607 ERROR [Scala Presentation Compiler [product]] - System.err - at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$61.apply(Typers.scala:3089) 2014-08-18 14:08:07,607 ERROR [Scala Presentation Compiler [product]] - System.err - at scala.collection.immutable.List.loop$1(List.scala:172) 2014-08-18 14:08:07,607 ERROR [Scala Presentation Compiler [product]] - System.err - at scala.collection.immutable.List.mapConserve(List.scala:188) 2014-08-18 14:08:07,607 ERROR [Scala Presentation Compiler [product]] - System.err - at scala.tools.nsc.typechecker.Typers$Typer.typedStats(Typers.scala:3089) 2014-08-18 14:08:07,607 ERROR [Scala Presentation Compiler [product]] - System.err - at scala.tools.nsc.typechecker.Typers$Typer.typedPackageDef$1(Typers.scala:4916) 2014-08-18 14:08:07,607 ERROR [Scala Presentation Compiler [product]] - System.err - at scala.tools.nsc.typechecker.Typers$Typer.typedMemberDef$1(Typers.scala:5209) 2014-08-18 14:08:07,607 ERROR [Scala Presentation Compiler [product]] - System.err - at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5256) 2014-08-18 14:08:07,607 ERROR [Scala Presentation Compiler [product]] - System.err - at scala.tools.nsc.typechecker.Typers$Typer.runTyper$1(Typers.scala:5293) 2014-08-18 14:08:07,607 ERROR [Scala Presentation Compiler [product]] - System.err - at scala.tools.nsc.typechecker.Typers$Typer.scala$tools$nsc$typechecker$Typers$Typer$$typedInternal(Typers.scala:5320) 2014-08-18 14:08:07,607 ERROR [Scala Presentation Compiler [product]] - System.err - at scala.tools.nsc.typechecker.Typers$Typer.body$2(Typers.scala:5267) 2014-08-18 14:08:07,607 ERROR [Scala Presentation Compiler [product]] - System.err - at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5271) 2014-08-18 14:08:07,607 ERROR [Scala Presentation Compiler [product]] - System.err - at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5345) 2014-08-18 14:08:07,607 ERROR [Scala Presentation Compiler [product]] - System.err - at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3.apply(Analyzer.scala:102) 2014-08-18 14:08:07,607 ERROR [Scala Presentation Compiler [product]] - System.err - at scala.tools.nsc.Global$GlobalPhase.applyPhase(Global.scala:410) 2014-08-18 14:08:07,607 ERROR [Scala Presentation Compiler [product]] - System.err - at scala.tools.nsc.interactive.Global$TyperRun$$anonfun$applyPhase$1.apply(Global.scala:1217) 2014-08-18 14:08:07,607 ERROR [Scala Presentation Compiler [product]] - System.err - at scala.tools.nsc.interactive.Global$TyperRun$$anonfun$applyPhase$1.apply(Global.scala:1217) 2014-08-18 14:08:07,607 ERROR [Scala Presentation Compiler [product]] - System.err - at scala.reflect.internal.SymbolTable.enteringPhase(SymbolTable.scala:235) 2014-08-18 14:08:07,607 ERROR [Scala Presentation Compiler [product]] - System.err - at scala.tools.nsc.interactive.Global$TyperRun.applyPhase(Global.scala:1217) 2014-08-18 14:08:07,607 ERROR [Scala Presentation Compiler [product]] - System.err - at scala.tools.nsc.interactive.Global$TyperRun.typeCheck(Global.scala:1210) 2014-08-18 14:08:07,607 ERROR [Scala Presentation Compiler [product]] - System.err - at scala.tools.nsc.interactive.Global.scala$tools$nsc$interactive$Global$$typeCheck(Global.scala:659) 2014-08-18 14:08:07,607 ERROR [Scala Presentation Compiler [product]] - System.err - at scala.tools.nsc.interactive.Global$$anonfun$backgroundCompile$5$$anonfun$apply$8.apply(Global.scala:574) 2014-08-18 14:08:07,607 ERROR [Scala Presentation Compiler [product]] - System.err - at scala.tools.nsc.interactive.Global$$anonfun$backgroundCompile$5.apply(Global.scala:570) 2014-08-18 14:08:07,607 ERROR [Scala Presentation Compiler [product]] - System.err - at scala.tools.nsc.interactive.Global$$anonfun$backgroundCompile$5.apply(Global.scala:570) 2014-08-18 14:08:07,607 ERROR [Scala Presentation Compiler [product]] - System.err - at scala.collection.TraversableLike$WithFilter$$anonfun$foreach$1.apply(TraversableLike.scala:778) 2014-08-18 14:08:07,607 ERROR [Scala Presentation Compiler [product]] - System.err - at scala.collection.immutable.List.foreach(List.scala:381) 2014-08-18 14:08:07,607 ERROR [Scala Presentation Compiler [product]] - System.err - at scala.collection.TraversableLike$WithFilter.foreach(TraversableLike.scala:777) 2014-08-18 14:08:07,607 ERROR [Scala Presentation Compiler [product]] - System.err - at scala.tools.nsc.interactive.Global.backgroundCompile(Global.scala:570) 2014-08-18 14:08:07,607 ERROR [Scala Presentation Compiler [product]] - System.err - at scala.tools.nsc.interactive.PresentationCompilerThread.run(PresentationCompilerThread.scala:25) 2014-08-18 14:08:08,047 ERROR [org.eclipse.jface.text.reconciler.MonoReconciler] - ImplicitHighlightingPresenter - java.lang.AssertionError: assertion failed: object GenKortefa extends scala.AnyRef { def <init>() = { super.<init>(); () } }
Can anybody help to make a workaround? Thanks!
Leave a comment
I'll need some help on reproducing this problem. I am unable to trigger macro-paradise, and I don't find much documentation.
I tried multiple variation of the following command (changing location of the file, using full path, using -Xplugindirs, ...) as show in http://docs.scala-lang.org/overviews/macros/paradise.html , but I don't see any result.
I tried multiple variation of the following command (changing location of the file, using full path, using -Xplugindirs, ...) as show in http://docs.scala-lang.org/overviews/macros/paradise.html , but I don't see any result.
~/opt/scala-2.11.2/bin/scalac -Xplugin:paradise_2.11.2-2.0.1.jar -Xshow-phases
on 2014-08-20 01:17 *
By chromygabor
I created a github project for this: https://github.com/chromygabor/typeprovider
Sorry for the long interval, but I converted the project from gradle to sbt to be able to test it.
The issue does not depend on the build system.
I put some indicator into the macro, which displays the last run of the macro. Furthermore I created a screenshot, you can see the indicator and the behavior of ScalaIDE.
Message me if you need more details!
Thanks for your cooperation!
Sorry for the long interval, but I converted the project from gradle to sbt to be able to test it.
The issue does not depend on the build system.
I put some indicator into the macro, which displays the last run of the macro. Furthermore I created a screenshot, you can see the indicator and the behavior of ScalaIDE.
Message me if you need more details!
Thanks for your cooperation!
Thanks for the complete test case. I can reproduce the problem now.
It fails on an assert (Typers.scala#L1772). It looks like some state of the 'created' type is not right.
I played a bit with the code, I made the annotation create a
I'll try to ask people with more knowledge on this, to see if it is a real problem, and what could be done.
It fails on an assert (Typers.scala#L1772). It looks like some state of the 'created' type is not right.
I played a bit with the code, I made the annotation create a
class
instead of an object
, and it fails on a similar assert (Typers.scala#L1735).I'll try to ask people with more knowledge on this, to see if it is a real problem, and what could be done.
Check compiler plugins for version conflicts and cleanup
PC options in case of incompatibilities.
Compiler plugins (like macro-paradise) are cross-compiled with
the full Scala version, and they are not binary compatible across
minor versions. We acknowledge that and check it properly in the
classpath validator.
Compiler plugins can’t be instantiated in the PC unless the
project Scala version (Installation) is exactly the same as
the platform (the one Eclipse is running). This commit fixes PC
crashes due to such incompatibilities.
Re #1002226
Fix #1002358
Fix #1002186
Branch: master
Commit: scala-ide:56b056f83e
PC options in case of incompatibilities.
Compiler plugins (like macro-paradise) are cross-compiled with
the full Scala version, and they are not binary compatible across
minor versions. We acknowledge that and check it properly in the
classpath validator.
Compiler plugins can’t be instantiated in the PC unless the
project Scala version (Installation) is exactly the same as
the platform (the one Eclipse is running). This commit fixes PC
crashes due to such incompatibilities.
Re #1002226
Fix #1002358
Fix #1002186
Branch: master
Commit: scala-ide:56b056f83e