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

Java contravariant type is represented as Covariant #3091

Closed
juliamcclellan opened this issue Jul 25, 2023 · 0 comments · Fixed by #3092
Closed

Java contravariant type is represented as Covariant #3091

juliamcclellan opened this issue Jul 25, 2023 · 0 comments · Fixed by #3092
Labels

Comments

@juliamcclellan
Copy link
Contributor

juliamcclellan commented Jul 25, 2023

Describe the bug
The following are Java and Kotlin definitions of a function with a parameter with a contravariant type:

public void bar(java.util.List<? super String> param) {}
fun bar(param: List<in String>) {}

The Kotlin definition is correctly parsed as Contravariant with a bound of String, but the Java definition becomes Covariant with a bound of Object.

It seems like in the PSI model, a PsiWildcardType will always have an extendsBound of java.lang.Object, even if that is not explicitly written in the source. In DokkaPsiParser.getVariance, because the extendsBound is checked first, wildcard types will always turn into Covariants, even when they have a contravariant super bound.

Are you willing to provide a PR?
I think #3092 fixes the issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant