Skip to content

buildClassType

context(session: KaSession)
fun buildClassType(classId: ClassId, init: KaClassTypeBuilder.() -> Unit = {}): KaType

Builds a class type with the given class ID.

A generic class type can be built by providing type arguments using the init block. The caller is supposed to provide the correct number of type arguments for the class.

For Kotlin built-in types, consider using the overload that accepts a KaClassLikeSymbol instead: buildClassType(builtinTypes.string).

Example

buildClassType(ClassId.fromString("kotlin/collections/List")) {
    argument(buildClassType(ClassId.fromString("kotlin/String")))
}
context(session: KaSession)
fun buildClassType(symbol: KaClassLikeSymbol, init: KaClassTypeBuilder.() -> Unit = {}): KaType

Builds a class type with the given class symbol.

A generic class type can be built by providing type arguments using the init block. The caller is supposed to provide the correct number of type arguments for the class.

Example

buildClassType(builtinTypes.string)