JSSuperConstructorCall

org.scalajs.ir.Trees.JSSuperConstructorCall
sealed case class JSSuperConstructorCall(args: List[TreeOrJSSpread])(implicit pos: Position) extends Tree

Super constructor call in the constructor of a non-native JS class.

Exactly one such node must appear in the constructor of a non-native JS class, at the top-level (possibly as a direct child of a top-level Block). Any other use of this node is invalid.

Statements before this node, as well as the args, cannot contain any This() node. Statements after this node can use This().

After the execution of this node, it is guaranteed that all fields declared in the current class have been created and initialized. Up to that point, accessing any field declared in this class (e.g., through an overridden method called from the super constructor) is undefined behavior.

All in all, the shape of a constructor is therefore:

{
  statementsNotUsingThis();
  JSSuperConstructorCall(...argsNotUsingThis);
  statementsThatMayUseThis()
}

which currently translates to something of the following shape:

{
  statementsNotUsingThis();
  super(...argsNotUsingThis);
  this.privateField1 = 0;
  this["publicField2"] = false;
  statementsThatMayUseThis()
}

Attributes

Graph
Supertypes
trait Serializable
trait Product
trait Equals
class Tree
class IRNode
class Object
trait Matchable
class Any
Show all

Members list

Value members

Inherited methods

Attributes

Inherited from:
Product

Attributes

Inherited from:
Product
def show: String

Attributes

Inherited from:
IRNode

Concrete fields

val tpe: Type

Implicits

Implicits

implicit val pos: Position