Skip to content

Unresolved symbols assertion during pickling when using a 'by name' expression that defines a trait inside #10540

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
hmemcpy opened this issue Nov 28, 2020 · 1 comment · Fixed by #10912

Comments

@hmemcpy
Copy link

hmemcpy commented Nov 28, 2020

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)
        ...
@hmemcpy hmemcpy changed the title Unresolved symbols assertion during pickling when inlining a 'by name' expression that defines a trait inside Unresolved symbols assertion during pickling when using a 'by name' expression that defines a trait inside Nov 28, 2020
@smarter
Copy link
Member

smarter commented Dec 21, 2020

I'm going to close this as a duplicate of #10542 since the root cause for both of these issues is very likely the same and the other one has more discussion, but I'll copy your example there since it's helpful to have an example that triggers the problem in a different way, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants