-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Nonsensical TASTy for the SELFDEF of non-static object
with an explicit self =>
name.
#19019
Comments
…sses. Re-create the correct self type which is a term reference to the accompanying lazy val.
⭐ How to debug a weird compiler issue in 10 EASY steps! ⭐ This happens because:
This explains why:
|
Work around scala/scala3#19019: patch the SelfDef of inner module classes.
Compiler version
3.3.1
Minimized code
Output
Tree after typer:
Full decoded TASTy Tress
Chosen excerpts:
Remarks:
OK: The declared type of every module
VALDEF
is aTypeRef
of the module class, for exampleContainer.this.NonStaticObjectNoSelf[ModuleClass]
.OK: The type of the SELFDEF for the 3 first cases (both static objects, and the non-static object without
self =>
), is aSINGLETONtpt
of a term ref to theVALDEF
, for exampleContainer.this.NonStaticObjectNoSelf.type
.NOT OK: The type of the SELFDEF for the last case--the non-static object with a
self =>
-- is the this-type of its own module class, namelyNonStaticObjectWithSelf[ModuleClass].this.type
.Why is not OK? Because it creates a loop in the
superType
chain (orunderlying
) of that this type. Theunderlying
of the this-type is the self type; but theunderlying
of the self is the this-type!Expectation
I expect the type of the last SELFDEF to be consistent with the other three, and point to the singleton type of the accompanying VALDEF.
The text was updated successfully, but these errors were encountered: