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] Incorrect type parameter variances #1743

Closed
kuanyingchou opened this issue Feb 21, 2024 · 0 comments · Fixed by #1755
Closed

[KSP2] Incorrect type parameter variances #1743

kuanyingchou opened this issue Feb 21, 2024 · 0 comments · Fixed by #1755
Assignees
Labels
bug Something isn't working

Comments

@kuanyingchou
Copy link
Contributor

With generic interfaces:

interface Bar<T>
interface BarIn<in T>
interface BarOut<out T>

And this test:

fun KSDeclaration.printTypeParams() {
    val params = typeParameters.joinToString {
        "${it.variance} ${it.name.asString()}"
    }
    println("${simpleName.asString()} $params")
}
resolver.getClassDeclarationByName("Bar")!!.printTypeParams()
resolver.getClassDeclarationByName("BarIn")!!.printTypeParams()
resolver.getClassDeclarationByName("BarOut")!!.printTypeParams()

I got this with KSP1:

Bar INVARIANT T
BarIn CONTRAVARIANT T
BarOut COVARIANT T

But this with KSP2:

Bar INVARIANT T
BarIn COVARIANT T
BarOut CONTRAVARIANT T

Tested with 2.0.0-Beta3-1.0.18-20240219.110134-28 and a0cd777.

@neetopia neetopia self-assigned this Feb 21, 2024
@neetopia neetopia added the bug Something isn't working label Feb 21, 2024
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