Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
bcorso opened this issue Feb 19, 2025 · 0 comments · Fixed by #2351
Closed

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

bcorso opened this issue Feb 19, 2025 · 0 comments · Fixed by #2351
Milestone

Comments

@bcorso
Copy link

bcorso commented Feb 19, 2025

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.

@ting-yuan ting-yuan modified the milestones: 1.0.0, 1.0.31 Feb 21, 2025
@ting-yuan ting-yuan linked a pull request Feb 26, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants