Closed
Description
An annotation that refers to parameters or variables compiles fine, but using a method or class with such annotation can lead to this error.
Seems to be easier to hit with separate compilation.
Test A (type parameter):
class Annot[T] extends scala.annotation.Annotation
class D[T](val f: Int@Annot[T])
object A{
def main(a:Array[String]) = {
val c = new D[Int](1)
c.f
}
}
Output:
exception occurred while compiling A.scala
java.lang.AssertionError: assertion failed: unresolved symbols: type T when pickling A.scala while compiling A.scala
Exception in thread "main" java.lang.AssertionError: assertion failed: unresolved symbols: type T when pickling A.scala
at scala.Predef$.assert(Predef.scala:223)
at dotty.tools.dotc.core.tasty.TreePickler.pickle(TreePickler.scala:691)
at dotty.tools.dotc.transform.Pickler.$anonfun$run$3(Pickler.scala:60)
at dotty.tools.dotc.transform.Pickler.$anonfun$run$3$adapted(Pickler.scala:53)
at scala.collection.immutable.List.foreach(List.scala:392)
at dotty.tools.dotc.transform.Pickler.$anonfun$run$2(Pickler.scala:53)
at dotty.tools.dotc.transform.Pickler.$anonfun$run$2$adapted(Pickler.scala:52)
at scala.collection.immutable.List.foreach(List.scala:392)
at dotty.tools.dotc.transform.Pickler.run(Pickler.scala:52)
at dotty.tools.dotc.core.Phases$Phase.$anonfun$runOn$1(Phases.scala:306)
at scala.collection.immutable.List.map(List.scala:286)
at dotty.tools.dotc.core.Phases$Phase.runOn(Phases.scala:304)
at dotty.tools.dotc.transform.Pickler.runOn(Pickler.scala:87)
at dotty.tools.dotc.Run.$anonfun$compileUnits$3(Run.scala:158)
at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
at dotty.tools.dotc.util.Stats$.trackTime(Stats.scala:49)
at dotty.tools.dotc.Run.$anonfun$compileUnits$2(Run.scala:155)
at dotty.tools.dotc.Run.$anonfun$compileUnits$2$adapted(Run.scala:153)
at scala.collection.IndexedSeqOptimized.foreach(IndexedSeqOptimized.scala:36)
at scala.collection.IndexedSeqOptimized.foreach$(IndexedSeqOptimized.scala:33)
at scala.collection.mutable.ArrayOps$ofRef.foreach(ArrayOps.scala:198)
at dotty.tools.dotc.Run.runPhases$1(Run.scala:153)
at dotty.tools.dotc.Run.$anonfun$compileUnits$1(Run.scala:178)
at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:102)
at dotty.tools.dotc.Run.compileUnits(Run.scala:133)
at dotty.tools.dotc.Run.compileSources(Run.scala:120)
at dotty.tools.dotc.Run.compile(Run.scala:104)
at dotty.tools.dotc.Driver.doCompile(Driver.scala:33)
at dotty.tools.dotc.Driver.process(Driver.scala:166)
at dotty.tools.dotc.Driver.process(Driver.scala:135)
at dotty.tools.dotc.Driver.process(Driver.scala:147)
at dotty.tools.dotc.Driver.main(Driver.scala:174)
at dotty.tools.dotc.Main.main(Main.scala)
Test B (value parameter):
First compile B_1.scala:
class Annot(val x: Int) extends scala.annotation.Annotation
object B_1{
def m(x: Int): Int @Annot(x) = 1
}
Then compile B_2.scala:
object B_2{
def main(a: Array[String]) = {
val v = B_1.m(2)
}
}
Output:
exception occurred while compiling B_2.scala
java.lang.AssertionError: assertion failed: unresolved symbols: value x when pickling B_2.scala while compiling B_2.scala
Exception in thread "main" java.lang.AssertionError: assertion failed: unresolved symbols: value x when pickling B_2.scala
at scala.Predef$.assert(Predef.scala:223)
at dotty.tools.dotc.core.tasty.TreePickler.pickle(TreePickler.scala:691)
...
Test C (local variable):
First compile C_1.scala:
class Annot(val x: Int) extends scala.annotation.Annotation
class D[T](val f: T)
object C_1{
def m() = {
val y = 1
new D[Int@Annot(y)](2)
}
}
Then compile C_2.scala:
object C_2{
def main(a:Array[String]) = {
val z = C_1.m()
}
}
Output:
exception occurred while compiling C_2.scala
java.lang.AssertionError: assertion failed: unresolved symbols: value y when pickling C_2.scala while compiling C_2.scala
Exception in thread "main" java.lang.AssertionError: assertion failed: unresolved symbols: value y when pickling C_2.scala
at scala.Predef$.assert(Predef.scala:223)
at dotty.tools.dotc.core.tasty.TreePickler.pickle(TreePickler.scala:691)