Skip to content

Java contravariant type is represented as Covariant #3091

@juliamcclellan

Description

@juliamcclellan

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions