Represents the identity of a type or type constructor.
TypeId provides rich type identity information including:
- The type's name
- The owner (package/class/object where it's defined)
- Type parameters (for type constructors)
- Classification (nominal, alias, or opaque)
- Parent types and self type
- Annotations
The phantom type parameter A ensures type safety when working with TypeId values. In Scala 3, A is bounded by AnyKind to support higher-kinded types.
Type parameters
- A
-
The type (or type constructor) this TypeId represents
Attributes
- Companion
- object
- Source
- TypeId.scala
- Graph
-
- Supertypes
Members list
Value members
Abstract methods
Attributes
- Source
- TypeId.scala
Attributes
- Source
- TypeId.scala
Attributes
- Source
- TypeId.scala
Attributes
- Source
- TypeId.scala
Attributes
- Source
- TypeId.scala
Attributes
- Source
- TypeId.scala
Attributes
- Source
- TypeId.scala
Attributes
- Source
- TypeId.scala
Attributes
- Source
- TypeId.scala
Concrete methods
Attributes
- Source
- TypeId.scala
Returns the Class associated with this TypeId, if available.
Returns the Class associated with this TypeId, if available.
On the JVM, for nominal types, this returns the Class object corresponding to this type's fullName. On JS, always returns None.
Note: This only works for nominal types (not aliases or opaque types). For generic types, returns the erased class (e.g., List[Int] returns classOf[List[_]]).
Attributes
- Source
- TypeId.scala
Constructs an instance of the type represented by this TypeId using the provided arguments.
Constructs an instance of the type represented by this TypeId using the provided arguments.
On the JVM, this uses reflection to invoke the primary constructor. For known types (collections, java.time, etc.), optimized construction is used.
On JS, always returns Left with an error message.
Value parameters
- args
-
the constructor arguments
Attributes
- Returns
-
Right with the constructed instance, or Left with an error message
- Source
- TypeId.scala
Compares the receiver object (this) with the argument object (that) for equivalence.
Compares the receiver object (this) with the argument object (that) for equivalence.
Any implementation of this method should be an equivalence relation:
- It is reflexive: for any instance
xof typeAny,x.equals(x)should returntrue. - It is symmetric: for any instances
xandyof typeAny,x.equals(y)should returntrueif and only ify.equals(x)returnstrue. - It is transitive: for any instances
x,y, andzof typeAnyifx.equals(y)returnstrueandy.equals(z)returnstrue, thenx.equals(z)should returntrue.
If you override this method, you should verify that your implementation remains an equivalence relation. Additionally, when overriding this method it is usually necessary to override hashCode to ensure that objects which are "equal" (o1.equals(o2) returns true) hash to the same scala.Int. (o1.hashCode.equals(o2.hashCode)).
Value parameters
- that
-
the object to compare against this object for equality.
Attributes
- Returns
-
trueif the receiver object is equivalent to the argument;falseotherwise. - Definition Classes
-
Any
- Source
- TypeId.scala
Attributes
- Source
- TypeId.scala
Attributes
- Source
- TypeId.scala
Calculates a hash code value for the object.
Calculates a hash code value for the object.
The default hashing algorithm is platform dependent.
Note that it is allowed for two objects to have identical hash codes (o1.hashCode.equals(o2.hashCode)) yet not be equal (o1.equals(o2) returns false). A degenerate implementation could always return 0. However, it is required that if two objects are equal (o1.equals(o2) returns true) that they have identical hash codes (o1.hashCode.equals(o2.hashCode)). Therefore, when overriding this method, be sure to verify that the behavior is consistent with the equals method.
Attributes
- Returns
-
the hash code value for this object.
- Definition Classes
-
Any
- Source
- TypeId.scala
Attributes
- Source
- TypeId.scala
Attributes
- Source
- TypeId.scala
Returns true if this is an applied type (has type arguments)
Attributes
- Source
- TypeId.scala
Attributes
- Source
- TypeId.scala
Checks if the normalized type is scala.util.Either
Attributes
- Source
- TypeId.scala
Checks if this type is equivalent to another type (mutually subtypes).
Checks if this type is equivalent to another type (mutually subtypes).
Value parameters
- other
-
The type to compare with
Attributes
- Returns
-
true if both types are subtypes of each other
- Source
- TypeId.scala
Attributes
- Source
- TypeId.scala
Attributes
- Source
- TypeId.scala
Attributes
- Source
- TypeId.scala
Checks if the normalized type is scala.Option
Checks if the normalized type is a Scala Product
Attributes
- Source
- TypeId.scala
Attributes
- Source
- TypeId.scala
Checks if this type is a subtype of another type.
Checks if this type is a subtype of another type.
This method checks the type hierarchy using the extracted parent types. It handles:
- Direct subtype relationships (class extends trait)
- Enum cases being subtypes of their parent enum
- Sealed trait subtypes
- Transitive inheritance
- Variance-aware subtyping for applied types (List[Dog] <: List[Animal] for covariant)
Note: This is a best-effort check based on compile-time extracted information. For complex cases involving type parameters or implicit conversions, the check may return false even when a true subtype relationship exists at runtime.
Value parameters
- other
-
The potential supertype to check against
Attributes
- Returns
-
true if this type is a subtype of other
- Source
- TypeId.scala
Checks if the normalized type is a Scala sum type (Either or Option)
Checks if this type is a supertype of another type.
Checks if this type is a supertype of another type.
Value parameters
- other
-
The potential subtype to check against
Attributes
- Returns
-
true if this type is a supertype of other
- Source
- TypeId.scala
Attributes
- Source
- TypeId.scala
Checks if the normalized type is a Scala Tuple
Attributes
- Source
- TypeId.scala
Attributes
- Source
- TypeId.scala
Attributes
- Source
- TypeId.scala
Returns a string representation of the object.
Returns a string representation of the object.
The default representation is platform dependent.
Attributes
- Returns
-
a string representation of the object.
- Definition Classes
-
Any
- Source
- TypeId.scala
Concrete fields
Returns a ClassTag for this type, using the correct primitive ClassTag for primitive types (Int, Long, Float, Double, Boolean, Byte, Short, Char, Unit) and ClassTag.AnyRef for all reference types.
Returns a ClassTag for this type, using the correct primitive ClassTag for primitive types (Int, Long, Float, Double, Boolean, Byte, Short, Char, Unit) and ClassTag.AnyRef for all reference types.
This is useful for creating properly-typed arrays at runtime.
Attributes
- Source
- TypeId.scala