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

Annotations missing on KSTypeArgument of typealias #1679

Closed
bcorso opened this issue Jan 11, 2024 · 1 comment · Fixed by #1684
Closed

Annotations missing on KSTypeArgument of typealias #1679

bcorso opened this issue Jan 11, 2024 · 1 comment · Fixed by #1684
Labels
bug Something isn't working
Milestone

Comments

@bcorso
Copy link

bcorso commented Jan 11, 2024

We ran into a case in Dagger where the @JvmSuppressWildcards is missing in the following case:

interface MyType
typealias MyAlias = MyType
typealias MyListAlias = List<@JvmSuppressWildcards MyAlias>
fun method(): MyListAlias

In particular, if we try to resolve MyListAlias the @JvmSuppressWildcards annotation is now missing (I'm just printing the toString() here since it's easier, but actually getting the annotations from the type arguments gives the same result):

// Prints: List<MyType> instead of List<[@JvmSuppressWildcards] MyType>
println("${(method.returnType().declaration as KSTypeAlias).type.resolve()}") 

I've also checked that all annotations get dropped, not just @JvmSuppressWildcards.

I'm guessing this is related to the nested typealias, because the following cases with a single typealias seem to work fine:

interface MyType
typealias MyListAlias = List<@JvmSuppressWildcards MyType>
fun method(): MyListAlias

// This works!
// Prints: List<[@JvmSuppressWildcards] MyType>
println("${(method.returnType().declaration as KSTypeAlias).type.resolve()}") 
interface MyType
typealias MyAlias = MyType
fun method(): List<@JvmSuppressWildcards MyAlias>

// This works!
// Prints: List<[@JvmSuppressWildcards] MyType>
println("${(method.returnType().declaration as KSTypeAlias).type.resolve()}") 
@neetopia neetopia added this to the Dagger milestone Jan 11, 2024
@neetopia
Copy link
Collaborator

Offending line might be here
KSP expanded type alias too eagerly to the end.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants