This class does not change linearization.
This class does not change linearization.
Transforms the info of types to add the Inner$jsclass
fields.
Transforms the info of types to add the Inner$jsclass
fields.
This method was inspired by ExplicitOuter.transformInfo
.
Makes the references to inner JS class values explicit.
Roughly, for every inner JS class of the form:
this phase creates a field
Inner$jsclass
inOuter
to hold the JS class value forInner
. The rhs of that field is a call to a magic method, used to retain information that the back-end will need.These fields will be read by code generated in
ExplicitLocalJS
.A
$jsclass
field is also generated for classes declared inside *static JS objects*. Indeed, even though those classes have a unique, globally accessible class value, that class value needs to be *exposed* as a field of the enclosing object. In those cases, the rhs of the field is a direct call toruntime.constructorOf[classOf[Inner]]
.Finally, for *modules* declared inside static JS objects, we generate an explicit exposed getter as well. For non-static objects, scalac already generates a getter with the
@ExposedJSMember
annotation, so we do not need to do anything. But for static objects, it doesn't, so we have to do it ourselves here.To illustrate the two above paragraphs, for the following input:
this phase will generate
Note that this field must also be added to outer classes and traits coming from separate compilation, therefore this phase is an
InfoTransform
. Since thetransformInfo
also applies to classes defined in the current compilation unit, the tree traversal must not create the field symbols a second time when synthesizing theValDef
. Instead, it must reuse the same symbols thattransformInfo
will create.It seems the easiest way to do that is to run the entire
transform
"in the future", withexitingPhase(ExplicitInnerJS)
. This design is similar to howexplicitouter
works.