TypeId

zio.blocks.typeid.TypeId
See theTypeId companion object
sealed trait TypeId[A <: AnyKind] extends TypeIdPlatformSpecific

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
class Object
trait Matchable
class Any

Members list

Value members

Abstract methods

def aliasedTo: Option[TypeRepr]

Attributes

Source
TypeId.scala
def annotations: List[Annotation]

Attributes

Source
TypeId.scala

Attributes

Source
TypeId.scala
def name: String

Attributes

Source
TypeId.scala
def owner: Owner

Attributes

Source
TypeId.scala
def representation: Option[TypeRepr]

Attributes

Source
TypeId.scala
def selfType: Option[TypeRepr]

Attributes

Source
TypeId.scala
def typeArgs: List[TypeRepr]

Attributes

Source
TypeId.scala
def typeParams: List[TypeParam]

Attributes

Source
TypeId.scala

Concrete methods

final def arity: Int

Attributes

Source
TypeId.scala
final def clazz: Option[Class[_]]

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
final def construct(args: Chunk[AnyRef]): Either[String, Any]

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
override def equals(other: Any): Boolean

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 x of type Any, x.equals(x) should return true.
  • It is symmetric: for any instances x and y of type Any, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any instances x, y, and z of type Any if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.

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

true if the receiver object is equivalent to the argument; false otherwise.

Definition Classes
Any
Source
TypeId.scala
final def erased: Erased

Attributes

Source
TypeId.scala
final def fullName: String

Attributes

Source
TypeId.scala
override def hashCode(): Int

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
final def isAbstract: Boolean

Attributes

Source
TypeId.scala
final def isAlias: Boolean

Attributes

Source
TypeId.scala
final def isApplied: Boolean

Returns true if this is an applied type (has type arguments)

Returns true if this is an applied type (has type arguments)

Attributes

Source
TypeId.scala
final def isCaseClass: Boolean

Attributes

Source
TypeId.scala
final def isClass: Boolean

Attributes

Source
TypeId.scala
final def isEither: Boolean

Checks if the normalized type is scala.util.Either

Checks if the normalized type is scala.util.Either

Attributes

Source
TypeId.scala
final def isEnum: Boolean

Attributes

Source
TypeId.scala
def isEquivalentTo(other: TypeId[_ <: AnyKind]): Boolean

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
final def isMaybe: Boolean

Attributes

Source
TypeId.scala
final def isObject: Boolean

Attributes

Source
TypeId.scala
final def isOpaque: Boolean

Attributes

Source
TypeId.scala
final def isOption: Boolean

Checks if the normalized type is scala.Option

Checks if the normalized type is scala.Option

Attributes

Source
TypeId.scala
final def isProduct: Boolean

Checks if the normalized type is a Scala Product

Checks if the normalized type is a Scala Product

Attributes

Source
TypeId.scala
final def isProperType: Boolean

Attributes

Source
TypeId.scala
final def isSealed: Boolean

Attributes

Source
TypeId.scala
def isSubtypeOf(other: TypeId[_ <: AnyKind]): Boolean

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
final def isSum: Boolean

Checks if the normalized type is a Scala sum type (Either or Option)

Checks if the normalized type is a Scala sum type (Either or Option)

Attributes

Source
TypeId.scala
def isSupertypeOf(other: TypeId[_ <: AnyKind]): Boolean

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
final def isTrait: Boolean

Attributes

Source
TypeId.scala
final def isTuple: Boolean

Checks if the normalized type is a Scala Tuple

Checks if the normalized type is a Scala Tuple

Attributes

Source
TypeId.scala
final def isTypeConstructor: Boolean

Attributes

Source
TypeId.scala
final def isValueClass: Boolean

Attributes

Source
TypeId.scala
final def parents: List[TypeRepr]

Attributes

Source
TypeId.scala
override def toString: String

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

lazy val classTag: ClassTag[_]

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