JetBrains / JetBrains/java-annotations

Add @Covariant and @Contravariant annotations

未关闭
#20 4 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
Kotlin
星标
463
派生
72
PR 合并指标
30 天内没有已合并 PR

描述

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.

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。