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.
Tired of Poor Kotlin Skills? Fix That With Deep Grasping!Learn More





