-
Notifications
You must be signed in to change notification settings - Fork 1.1k
NPE when inlining a macro that uses a by-name parameter defining a sealed trait #10542
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
Comments
@griggt Ah, looks very similar indeed! |
The root cause of all this is that we currently cannot reliably copy non-trivial class hierarchies, and inlining implies copying. To fix this we'd have to look at |
I just closed #10540 as a duplicate of this one, the example and crash are different but the root cause is likely the same: Minimized codetrait 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:
|
Thanks! Just to emphasize, the assertion error here only happens when using an Array, just something to keep in mind. |
Uh oh!
There was an error while loading. Please reload this page.
I found an issue when porting a macro to Scala 3 (using 3.0.0-M1). Took me a while to find it (see it on Scastie), but I managed to narrow it down to:
Minimized code
Attempting to compile this, gives me an NPE with the following stacktrace:
Output (click arrow to expand)
Removing the
sealed
keyword does not cause the issue. Changing the by-name to a lambda() => A
also does not cause the issue.Finally, this might be related somewhat to #10540 which I reported earlier, it's a similar test defining some traits inside a body that is used as a by-name parameter.
The text was updated successfully, but these errors were encountered: