JetBrains / JetBrains/java-annotations

Add @Covariant and @Contravariant annotations

Open
#20 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
Kotlin
Stars
463
Forks
72
PR merge metrics
No merged PRs in 30d

Description

As a library developer, I want to be able to add some annotations to mark the variance of the type parameters of a class. IDE can give the following hint based on this annotation:
- Report a warning when contravariant type parameter T is used as a function parameter type
- Report a warning when covariant type parameter T is used as a function return type
- For function parameter types, prompt user to use `Function` (take `java.util.function.Function` as an example) instead of `Function`

And the jvm-based language can choose to understand this annotation (e.g. kotlin can understand `class C<@Covariant T>` as `class C`. This is convenient for developers to provide Kotlin-friendly APIs using pure Java.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.