-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Compiler crash using export instead of import #13490
Comments
@dwijnand and I were able to minimize this further: object MyApi:
enum MyEnum:
case A
object Test:
export MyApi.MyEnum
import MyEnum.A
def foo: Any = A an alternative form, not sure if more or less minimized: object MyApi:
enum MyEnum:
case A
object Test:
export MyApi.MyEnum
object Test2:
import Test.MyEnum.A
def foo: Any = A |
after typer, Test2:
import Test.MyEnum.A
def foo: Any = MyApi.MyEnum#A already the but maybe it's normal and we're just not used to seeing it then going into erasure, we have Test:
final def MyEnum: MyApi.MyEnum.type = MyApi.MyEnum
@Child[(MyApi.MyEnum.A : MyApi.MyEnum)] final type MyEnum = MyApi.MyEnum
Test2:
def foo: Any = MyApi.MyEnum#A and coming out of erasure, Test:
final def MyEnum(): MyApi.MyEnum = MyApi.MyEnum // forwarder made by `export`; singleton type widened (?!)
Test2:
def foo(): Object = ((): MyApi.MyEnum)#A and when we compile the same code without the that's as far Dale and I got with this in our session today. neither of has any familiarity with the internals of the erasure phase, so I guess the next thing is just to go in either with logging and printlns or a debugger and try and figure where exactly this |
one thing we've done on the wip branch is separate the code into
(This only works because Dale tweaked the build so that
oops: it's neither. as we said above, in the enum desugaring so we now suspect |
We found what seems to be a fix, but we'd still like to understand better how this came about.
In private def fieldOp(field: Symbol, isLoad: Boolean, specificReceiver: Symbol): Unit = {
- val useSpecificReceiver = specificReceiver != null && !field.isScalaStatic
+ val useSpecificReceiver = specificReceiver != null && specificReceiver != NoSymbol && !field.isScalaStatic fa42b81 is relevant; it's a port from Scala 2 to 3 and in both versions, in the old code so there's precedent for simply adding the check back in and perhaps that's the fix we should make, but regardless, we would like to understand where the |
We could go one level up and alter this code (in
or, Dale has an idea of handling it during erasure, that he'll explain or even just PR. |
Compiler version
3.1.1-RC1-bin-20210907-a47a81a-NIGHTLY
Minimized code
Note: changing
export MyApi.*
toimport MyApi.*
works just fine.Output
Expectation
No crash & no compile error
The text was updated successfully, but these errors were encountered: