Class

org.scalajs.nscplugin

ExplicitInnerJS

Related Doc: package nscplugin

Permalink

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)

    Permalink

Type Members

  1. implicit class BTypesCompat extends AnyRef

    Permalink
    Definition Classes
    CompatComponent
  2. class ExplicitInnerJSTransformer extends TypingTransformer

    Permalink
  3. implicit final class GlobalCompat extends AnyRef

    Permalink
    Definition Classes
    CompatComponent
  4. class Phase extends scala.tools.nsc.transform.InfoTransform.Phase

    Permalink
    Definition Classes
    InfoTransform
  5. type SAMFunctionCompat = SAMFunction

    Permalink
    Definition Classes
    CompatComponent
  6. implicit final class SAMFunctionCompatOps extends AnyRef

    Permalink
    Definition Classes
    CompatComponent
  7. abstract class StdPhase extends GlobalPhase

    Permalink
    Definition Classes
    SubComponent
  8. implicit final class StdTermNamesCompat extends AnyRef

    Permalink
    Definition Classes
    CompatComponent
  9. implicit final class StdTypeNamesCompat extends AnyRef

    Permalink
    Definition Classes
    CompatComponent
  10. implicit final class SymbolCompat extends AnyRef

    Permalink
    Definition Classes
    CompatComponent
  11. implicit final class TyperCompat extends AnyRef

    Permalink
    Definition Classes
    CompatComponent
  12. abstract class TypingTransformer extends scala.tools.nsc.Global.Transformer

    Permalink
    Definition Classes
    TypingTransformers

Abstract Value Members

  1. abstract val jsAddons: JSGlobalAddons { val global: ExplicitInnerJS.this.global.type }

    Permalink
  2. abstract val runsAfter: List[String]

    Permalink
    Definition Classes
    SubComponent

Concrete Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. object SAMFunctionAttachCompat

    Permalink
    Definition Classes
    CompatComponent
  5. object SAMFunctionAttachCompatDef

    Permalink
    Definition Classes
    CompatComponent
  6. lazy val SAMFunctionCompat: SAMFunction.type

    Permalink
    Definition Classes
    CompatComponent
  7. val WarningCategory: CompatComponent.WarningCategoryCompat.Reporting.WarningCategory.type

    Permalink
    Definition Classes
    CompatComponent
  8. object WarningCategoryCompat

    Permalink
    Definition Classes
    CompatComponent
  9. final def afterOwnPhase[T](op: ⇒ T): T

    Permalink
    Definition Classes
    SubComponent
    Annotations
    @inline()
  10. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  11. final def beforeOwnPhase[T](op: ⇒ T): T

    Permalink
    Definition Classes
    SubComponent
    Annotations
    @inline()
  12. def changesBaseClasses: Boolean

    Permalink

    This class does not change linearization.

    This class does not change linearization.

    Attributes
    protected
    Definition Classes
    ExplicitInnerJS → InfoTransform
  13. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  14. def description: String

    Permalink
    Definition Classes
    ExplicitInnerJS → PluginComponent
  15. def enabled: Boolean

    Permalink
    Definition Classes
    SubComponent
  16. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  17. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  18. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  19. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  20. val global: G

    Permalink
    Definition Classes
    ExplicitInnerJSCompatComponent → TypingTransformers → SubComponent
  21. def hashCode(): Int

    Permalink
    Definition Classes
    SubComponent → AnyRef → Any
  22. val initial: Boolean

    Permalink
    Definition Classes
    SubComponent
  23. final val internal: Boolean(false)

    Permalink
    Definition Classes
    PluginComponent → SubComponent
  24. def isImplClass(sym: G.Symbol): Boolean

    Permalink
    Definition Classes
    CompatComponent
  25. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  26. lazy val isScala211: Boolean

    Permalink
    Definition Classes
    CompatComponent
  27. def keepsTypeParams: Boolean

    Permalink
    Attributes
    protected
    Definition Classes
    InfoTransform
  28. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  29. def newPhase(prev: scala.tools.nsc.Phase): StdPhase

    Permalink
    Definition Classes
    InfoTransform → Transform → SubComponent
  30. def newTransformer(unit: G.CompilationUnit): G.Transformer

    Permalink
    Attributes
    protected
    Definition Classes
    ExplicitInnerJS → Transform
  31. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  32. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  33. def ownPhase: scala.tools.nsc.Phase

    Permalink
    Definition Classes
    SubComponent
  34. val phaseName: String

    Permalink
    Definition Classes
    ExplicitInnerJS → SubComponent
  35. def phaseNewFlags: Long

    Permalink
    Definition Classes
    SubComponent
  36. def phaseNextFlags: Long

    Permalink
    Definition Classes
    SubComponent
  37. val requires: List[String]

    Permalink
    Definition Classes
    SubComponent
  38. val runsBefore: List[String]

    Permalink
    Definition Classes
    SubComponent
  39. val runsRightAfter: Option[String]

    Permalink
    Definition Classes
    PluginComponent → SubComponent
  40. lazy val scalaUsesImplClasses: Boolean

    Permalink
    Definition Classes
    CompatComponent
  41. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  42. val terminal: Boolean

    Permalink
    Definition Classes
    SubComponent
  43. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  44. def transformInfo(sym: G.Symbol, tp: G.Type): G.Type

    Permalink

    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
  45. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  46. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  47. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @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