A type alias in Kotlin provides an alternative name for an existing type. It does not introduce a new type into the type system; rather, it acts as a compile-time substitution. During compilation, the Kotlin compiler replaces the alias with its underlying target type, meaning the alias and the original type are strictly identical and interchangeable in the generated bytecode.Documentation Index
Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
Use this file to discover all available pages before exploring further.
Syntax
Type aliases are declared using thetypealias keyword, followed by the new identifier, an assignment operator, and the target type.
Technical Characteristics
- Top-Level Declaration: Type aliases must be declared at the top level of a file. They cannot be nested inside classes, objects, interfaces, or local scopes (functions).
- Type Identity: Because a type alias is not a distinct type, an instance of the alias can be assigned to a variable of the original type, and vice versa, without any type casting or conversion.
- Visibility Modifiers: Type aliases support standard visibility modifiers (
public,private,internal). A type alias cannot have a more permissive visibility than its underlying target type.
Structural Mechanics
1. Standard Type Substitution A direct mapping to an existing class, interface, or parameterized type.Reflection and Type Checking
Because type aliases are resolved during compilation, runtime type checks (is operator) and reflection evaluate the underlying type, not the alias. Class literals using the alias are fully supported by the compiler and evaluate directly to the class literal of the underlying target type.
Master Kotlin with Deep Grasping Methodology!Learn More





