Types

org.scalajs.ir.Types
object Types

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type
Types.type

Members list

Type members

Classlikes

case object AnyType extends Type

Any type (the top type of this type system). A variable of this type can contain any value, including undefined and null and any JS value. This type supports a very limited set of Scala operations, the ones common to all values. Basically only reference equality tests and instance tests. It also supports all JavaScript operations, since all Scala objects are also genuine JavaScript objects. The type java.lang.Object in the back-end maps to AnyType because it can hold JS values (not only instances of Scala.js classes).

Any type (the top type of this type system). A variable of this type can contain any value, including undefined and null and any JS value. This type supports a very limited set of Scala operations, the ones common to all values. Basically only reference equality tests and instance tests. It also supports all JavaScript operations, since all Scala objects are also genuine JavaScript objects. The type java.lang.Object in the back-end maps to AnyType because it can hold JS values (not only instances of Scala.js classes).

Attributes

Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
class Type
class Object
trait Matchable
class Any
Show all
Self type
AnyType.type
final case class ArrayType(arrayTypeRef: ArrayTypeRef) extends Type

Array type.

Array type.

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Type
class Object
trait Matchable
class Any
Show all
final case class ArrayTypeRef(base: NonArrayTypeRef, dimensions: Int) extends TypeRef

Array type.

Array type.

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class TypeRef
class Object
trait Matchable
class Any
Show all
object ArrayTypeRef

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
case object BooleanType extends PrimTypeWithRef

Boolean type. It does not accept null nor undefined.

Boolean type. It does not accept null nor undefined.

Attributes

Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
class PrimType
class Type
class Object
trait Matchable
class Any
Show all
Self type
case object ByteType extends PrimTypeWithRef

8-bit signed integer type. It does not accept null nor undefined.

8-bit signed integer type. It does not accept null nor undefined.

Attributes

Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
class PrimType
class Type
class Object
trait Matchable
class Any
Show all
Self type
ByteType.type
case object CharType extends PrimTypeWithRef

Char type, a 16-bit UTF-16 code unit. It does not accept null nor undefined.

Char type, a 16-bit UTF-16 code unit. It does not accept null nor undefined.

Attributes

Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
class PrimType
class Type
class Object
trait Matchable
class Any
Show all
Self type
CharType.type
final case class ClassRef(className: ClassName) extends NonArrayTypeRef

Class (or interface) type.

Class (or interface) type.

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class TypeRef
class Object
trait Matchable
class Any
Show all
final case class ClassType(className: ClassName) extends Type

Class (or interface) type.

Class (or interface) type.

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Type
class Object
trait Matchable
class Any
Show all
case object DoubleType extends PrimTypeWithRef

Double type (64-bit). It does not accept null nor undefined.

Double type (64-bit). It does not accept null nor undefined.

Attributes

Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
class PrimType
class Type
class Object
trait Matchable
class Any
Show all
Self type
DoubleType.type
case object FloatType extends PrimTypeWithRef

Float type (32-bit). It does not accept null nor undefined.

Float type (32-bit). It does not accept null nor undefined.

Attributes

Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
class PrimType
class Type
class Object
trait Matchable
class Any
Show all
Self type
FloatType.type
case object IntType extends PrimTypeWithRef

32-bit signed integer type. It does not accept null nor undefined.

32-bit signed integer type. It does not accept null nor undefined.

Attributes

Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
class PrimType
class Type
class Object
trait Matchable
class Any
Show all
Self type
IntType.type
case object LongType extends PrimTypeWithRef

64-bit signed integer type. It does not accept null nor undefined.

64-bit signed integer type. It does not accept null nor undefined.

Attributes

Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
class PrimType
class Type
class Object
trait Matchable
class Any
Show all
Self type
LongType.type
case object NoType extends PrimTypeWithRef

No type.

No type.

Attributes

Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
class PrimType
class Type
class Object
trait Matchable
class Any
Show all
Self type
NoType.type
sealed abstract class NonArrayTypeRef extends TypeRef

Attributes

Supertypes
class TypeRef
class Object
trait Matchable
class Any
Known subtypes
class ClassRef
class PrimRef
case object NothingType extends PrimTypeWithRef

Nothing type (the bottom type of this type system). Expressions from which one can never come back are typed as Nothing. For example, throw and return.

Nothing type (the bottom type of this type system). Expressions from which one can never come back are typed as Nothing. For example, throw and return.

Attributes

Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
class PrimType
class Type
class Object
trait Matchable
class Any
Show all
Self type
case object NullType extends PrimTypeWithRef

The type of null. It does not accept undefined. The null type is a subtype of all class types and array types.

The type of null. It does not accept undefined. The null type is a subtype of all class types and array types.

Attributes

Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
class PrimType
class Type
class Object
trait Matchable
class Any
Show all
Self type
NullType.type
final case class PrimRef extends NonArrayTypeRef

Primitive type reference.

Primitive type reference.

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class TypeRef
class Object
trait Matchable
class Any
Show all
sealed abstract class PrimType extends Type

Attributes

Supertypes
class Type
class Object
trait Matchable
class Any
Known subtypes
object BooleanType
object ByteType
object CharType
object DoubleType
object FloatType
object IntType
object LongType
object NoType
object NothingType
object NullType
object ShortType
object StringType
object UndefType
Show all
sealed abstract class PrimTypeWithRef extends PrimType

Attributes

Supertypes
class PrimType
class Type
class Object
trait Matchable
class Any
Known subtypes
object BooleanType
object ByteType
object CharType
object DoubleType
object FloatType
object IntType
object LongType
object NoType
object NothingType
object NullType
object ShortType
Show all
final case class RecordType(fields: List[Field]) extends Type

Record type. Used by the optimizer to inline classes as records with multiple fields. They are desugared as several local variables by JSDesugaring. Record types cannot cross method boundaries, so they cannot appear as the type of fields or parameters, nor as result types of methods. The compiler itself never generates record types.

Record type. Used by the optimizer to inline classes as records with multiple fields. They are desugared as several local variables by JSDesugaring. Record types cannot cross method boundaries, so they cannot appear as the type of fields or parameters, nor as result types of methods. The compiler itself never generates record types.

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Type
class Object
trait Matchable
class Any
Show all
object RecordType

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
RecordType.type
case object ShortType extends PrimTypeWithRef

16-bit signed integer type. It does not accept null nor undefined.

16-bit signed integer type. It does not accept null nor undefined.

Attributes

Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
class PrimType
class Type
class Object
trait Matchable
class Any
Show all
Self type
ShortType.type
case object StringType extends PrimType

String type. It does not accept null nor undefined.

String type. It does not accept null nor undefined.

Attributes

Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
class PrimType
class Type
class Object
trait Matchable
class Any
Show all
Self type
StringType.type
sealed abstract class Type

Type of a term (expression or statement) in the IR.

Type of a term (expression or statement) in the IR.

There is a many-to-one relationship from TypeRefs to Types, because java.lang.Object and JS types all collapse to AnyType.

In fact, there are two Types that do not have any real equivalent in type refs: StringType and UndefType, as they refer to the non-null variants of java.lang.String and java.lang.Void, respectively.

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
object AnyType
class ArrayType
class ClassType
class PrimType
object BooleanType
object ByteType
object CharType
object DoubleType
object FloatType
object IntType
object LongType
object NoType
object NothingType
object NullType
object ShortType
object StringType
object UndefType
class RecordType
Show all
sealed abstract class TypeRef

Type reference (allowed for classOf[], is/asInstanceOf[]).

Type reference (allowed for classOf[], is/asInstanceOf[]).

A TypeRef has exactly the same level of precision as a JVM type. There is a one-to-one relationship between a TypeRef and an instance of java.lang.Class at run-time. This means that:

  • All primitive types have their TypeRef (including scala.Byte and scala.Short), and they are different from their boxed versions.
  • JS types are not erased to any
  • Array types are like on the JVM

A TypeRef therefore uniquely identifies a classOf[T]. It is also the type refs that are used in method signatures, and which therefore dictate JVM/IR overloading.

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
class ArrayTypeRef
class ClassRef
class PrimRef
case object UndefType extends PrimType

The type of undefined.

The type of undefined.

Attributes

Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
class PrimType
class Type
class Object
trait Matchable
class Any
Show all
Self type
UndefType.type

Value members

Concrete methods

def isSubtype(lhs: Type, rhs: Type)(isSubclass: (ClassName, ClassName) => Boolean): Boolean

Tests whether a type lhs is a subtype of rhs (or equal).

Tests whether a type lhs is a subtype of rhs (or equal).

Value parameters

isSubclass

A function testing whether a class/interface is a subclass of another class/interface.

Attributes

def zeroOf(tpe: Type)(implicit pos: Position): Tree

Generates a literal zero of the given type.

Generates a literal zero of the given type.

Attributes

Concrete fields

final val BooleanRef: PrimRef
final val ByteRef: PrimRef
final val CharRef: PrimRef
final val DoubleRef: PrimRef
final val FloatRef: PrimRef
final val IntRef: PrimRef
final val LongRef: PrimRef
final val NothingRef: PrimRef
final val NullRef: PrimRef
final val ShortRef: PrimRef
final val VoidRef: PrimRef