Skip to content

[KSP2] KSPropertyDeclaration#type for typealias does not match its declaration. #2345

@bcorso

Description

@bcorso

This issue seems similar to #2325.

Consider the following source:

class Subject(val param: MyAlias<String>)
typealias MyAlias<T> = Foo<Bar<T>, Baz<T>>
class Foo<T1, T2>
class Bar<T>
class Baz<T>

With the following processor logic:

val subjectName = resolver.getKSNameFromString("Subject")
val subject = resolver.getClassDeclarationByName(subjectName)!!
val property = subject.getDeclaredProperties().single()
val propertyType = property.type.resolve()

println("${property.simpleName}: ${propertyType.declaration}: $propertyType")

Results in:

BACKEND: KSP1
param: MyAlias: [typealias MyAlias]<String>

BACKEND: KSP2
param: MyAlias: Foo<Bar<String>, Baz<String>>

The issue is that in KSP2, the KSPropertyDeclaration#type is expanded (i.e. no longer contains the type alias), but its KSType#declaration is a type alias. I would expect the type and its declaration to align as it does in KSP1.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions