-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Using nn
without -Yexplicit-nulls
Crashes in RC1 but not M3
#11631
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
Oh, I just read that Is that the case here? And would the solution be replacing |
Here's a minimization without trait MyTrait:
def a(): String = ""
class Nul
extension [T](x: T | Nul) inline def nnn: x.type & T = ???
class MyClass:
var myTrait: MyTrait|Null = null
def printA(): Unit = println(myTrait.nnn.a())
@main def runTest(): Unit =
val mt = new MyTrait:
override def a(): String = "hello world"
val mc = MyClass()
mc.myTrait = mt
mc.printA() It happens at inliner phase. Seems to be a consequence of moving inlining to its own phase. |
In fact, things seem to work if we replace the definition of var myTrait: MyTrait|Nul = ??? So it does seem to be related to Maybe a stopgap measure is to disallow |
Sounds good to me. Seems like a rare / low priority bug. I only encountered
by somehow forgetting to set explicit nulls.
Thanks for looking into it!
…On Sun, Mar 7, 2021, 2:45 AM odersky ***@***.***> wrote:
In fact, things seem to work if we replace the definition of myTrait
above with
var myTrait: MyTrait|Nul = ???
So it does seem to be related to Null handling in some way, after all.
Maybe a stopgap measure is to disallow nn unless -YexplicitNulls is set?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#11631 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABQOKNWMFH2NIA2KN7E3KYTTCNKMLANCNFSM4YXCRMWA>
.
|
Closed in #13604 |
Compiler version
3.0.0-RC1
(No crash in 3.0.0-M3)
Minimized code
Output
Enabling explicit nulls fixes this, but I think the program should still compile. I ran into this problem when making an (encapsulated) Scala.js Web Component. Web Components may only have 0-arg constructors.
The text was updated successfully, but these errors were encountered: