Description
In my attempts to port a macro to Scala 3, I stumbled on an issue that seems very similar to #5572 which was reported and fixed by @milessabin. Using his repro sample, I was able to reproduce the bug on 3.0.0-M1 (try it in Scastie)
When defining a trait inside the block passed to foo
, if used with an Array
, it will blow up with the exception below.
Changing the array to, say, a List
or a Vector
does not cause the issue, and moving the trait definition outside of the block also does not cause the issue.
Also seems that changing the by-name parameter to a lambda (e.g. () => A
) does not cause the issue either.
The original code crashed when defining a Vector of those trait instances, followed by a call to .toArray
, which caused the crash. I suspect this has possibly something to do with a ClassTag
?
Minimized code
trait Foo {
inline def foo[A](t: => A): Unit = ()
}
object Bar extends Foo
object Test {
Bar.foo {
trait T1
val array = Array(new T1 {})
}
}
Output (click arrow to expand)
Scastie output:
java.lang.AssertionError: assertion failed: unresolved symbols: �[33mtrait�[0m �[35mT1�[0m(line 8) when pickling /tmp/scastie7347053754411828221/src/main/scala/main.scala
at dotty.DottyPredef$.assertFail(DottyPredef.scala:17)
at dotty.tools.dotc.core.tasty.TreePickler.pickle(TreePickler.scala:765)
at dotty.tools.dotc.transform.Pickler.run$$anonfun$3$$anonfun$2(Pickler.scala:69)
at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:15)
at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:10)
at scala.collection.immutable.List.foreach(List.scala:333)
at dotty.tools.dotc.transform.Pickler.run$$anonfun$1(Pickler.scala:105)
...