c

org.scalajs.nscplugin

ExplicitInnerJS

abstract class ExplicitInnerJS[G <: Global with Singleton] extends PluginComponent with InfoTransform with TypingTransformers with CompatComponent

Makes the references to inner JS class values explicit.

Roughly, for every inner JS class of the form:

class Outer {
  class Inner extends ParentJSClass
}

this phase creates a field Inner$jsclass in Outer to hold the JS class value for Inner. The rhs of that field is a call to a magic method, used to retain information that the back-end will need.

class Outer {
  <synthetic> val Inner$jsclass: AnyRef =
    createJSClass(classOf[Inner], js.constructorOf[ParentJSClass])

  class Inner extends ParentJSClass
}

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 to runtime.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:

object Outer extends js.Object {
  class InnerClass extends ParentJSClass
  object InnerObject extends SomeOtherJSClass
}

this phase will generate

object Outer extends js.Object {
  ...

  @ExposedJSMember @JSName("InnerClass")
  val InnerClass$jsclass: AnyRef = runtime.constructorOf(classOf[InnerClass])

  @ExposedJSMember @JSName("InnerObject")
  def InnerObject$jsobject: AnyRef = InnerObject
}

Note that this field must also be added to outer classes and traits coming from separate compilation, therefore this phase is an InfoTransform. Since the transformInfo also applies to classes defined in the current compilation unit, the tree traversal must not create the field symbols a second time when synthesizing the ValDef. Instead, it must reuse the same symbols that transformInfo will create.

It seems the easiest way to do that is to run the entire transform "in the future", with exitingPhase(ExplicitInnerJS). This design is similar to how explicitouter works.

Linear Supertypes
CompatComponent, TypingTransformers, InfoTransform, Transform, PluginComponent, SubComponent, AnyRef, Any
Known Subclasses
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. ExplicitInnerJS
  2. CompatComponent
  3. TypingTransformers
  4. InfoTransform
  5. Transform
  6. PluginComponent
  7. SubComponent
  8. AnyRef
  9. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new ExplicitInnerJS(global: G)

Type Members

  1. implicit class BTypesCompat extends AnyRef
    Definition Classes
    CompatComponent
  2. implicit final class GlobalCompat extends AnyRef
    Definition Classes
    CompatComponent
  3. implicit final class SAMFunctionCompatOps extends AnyRef
    Definition Classes
    CompatComponent
  4. implicit final class SymbolCompat extends AnyRef
    Definition Classes
    CompatComponent
  5. implicit final class TyperCompat extends AnyRef
    Definition Classes
    CompatComponent
  6. class ExplicitInnerJSTransformer extends TypingTransformer
  7. class Phase extends scala.tools.nsc.transform.InfoTransform.Phase
    Definition Classes
    InfoTransform
  8. abstract class StdPhase extends GlobalPhase
    Definition Classes
    SubComponent
  9. abstract class TypingTransformer extends scala.tools.nsc.Global.Transformer
    Definition Classes
    TypingTransformers

Abstract Value Members

  1. abstract val jsAddons: JSGlobalAddons { val global: ExplicitInnerJS.this.global.type }
  2. abstract val runsAfter: List[String]
    Definition Classes
    SubComponent

Concrete Value Members

  1. object AttachmentsCompat
    Definition Classes
    CompatComponent
  2. object AttachmentsCompatDef
    Definition Classes
    CompatComponent
  3. object WarningCategoryCompat
    Definition Classes
    CompatComponent
  4. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  5. final def ##(): Int
    Definition Classes
    AnyRef → Any
  6. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  7. lazy val DottyEnumSingletonCompat: DottyEnumSingleton.type
    Definition Classes
    CompatComponent
  8. val WarningCategory: CompatComponent.WarningCategoryCompat.Reporting.WarningCategory.type
    Definition Classes
    CompatComponent
  9. final def afterOwnPhase[T](op: ⇒ T): T
    Definition Classes
    SubComponent
    Annotations
    @inline()
  10. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  11. final def beforeOwnPhase[T](op: ⇒ T): T
    Definition Classes
    SubComponent
    Annotations
    @inline()
  12. def changesBaseClasses: Boolean

    This class does not change linearization.

    This class does not change linearization.

    Attributes
    protected
    Definition Classes
    ExplicitInnerJS → InfoTransform
  13. def clone(): AnyRef
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @native() @throws( ... )
  14. def description: String
    Definition Classes
    ExplicitInnerJS → PluginComponent
  15. def enabled: Boolean
    Definition Classes
    SubComponent
  16. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  17. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  18. def finalize(): Unit
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  19. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  20. val global: G
    Definition Classes
    ExplicitInnerJSCompatComponent → TypingTransformers → SubComponent
  21. def hashCode(): Int
    Definition Classes
    SubComponent → AnyRef → Any
  22. val initial: Boolean
    Definition Classes
    SubComponent
  23. final val internal: Boolean(false)
    Definition Classes
    PluginComponent → SubComponent
  24. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  25. def keepsTypeParams: Boolean
    Attributes
    protected
    Definition Classes
    InfoTransform
  26. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  27. def newPhase(prev: scala.tools.nsc.Phase): StdPhase
    Definition Classes
    InfoTransform → Transform → SubComponent
  28. def newTransformer(unit: G.CompilationUnit): G.Transformer
    Attributes
    protected
    Definition Classes
    ExplicitInnerJS → Transform
  29. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  30. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  31. def ownPhase: scala.tools.nsc.Phase
    Definition Classes
    SubComponent
  32. val phaseName: String
    Definition Classes
    ExplicitInnerJS → SubComponent
  33. def phaseNewFlags: Long
    Definition Classes
    SubComponent
  34. def phaseNextFlags: Long
    Definition Classes
    SubComponent
  35. val requires: List[String]
    Definition Classes
    SubComponent
  36. val runsBefore: List[String]
    Definition Classes
    SubComponent
  37. val runsRightAfter: Option[String]
    Definition Classes
    PluginComponent → SubComponent
  38. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  39. val terminal: Boolean
    Definition Classes
    SubComponent
  40. def toString(): String
    Definition Classes
    AnyRef → Any
  41. def transformInfo(sym: G.Symbol, tp: G.Type): G.Type

    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.

    Definition Classes
    ExplicitInnerJS → InfoTransform
  42. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  43. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  44. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @throws( ... )

Inherited from CompatComponent

Inherited from TypingTransformers

Inherited from InfoTransform

Inherited from Transform

Inherited from PluginComponent

Inherited from SubComponent

Inherited from AnyRef

Inherited from Any

Ungrouped