You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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<? extends T, ? super U> (take java.util.function.Function as an example) instead of Function<T, U>
And the jvm-based language can choose to understand this annotation (e.g. kotlin can understand class C<@Covariant T> as class C<out T>. This is convenient for developers to provide Kotlin-friendly APIs using pure Java.
The text was updated successfully, but these errors were encountered:
This JEP has not been updated in three years, and I am confused about its status and have no confidence in its delivery in the next few years. Even if Java 17 can implement this feature, many libraries still have to stay in Java 8 or even Java 5 for a long time. I think it is very meaningful to add corresponding annotations.
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:
Function<? extends T, ? super U>
(takejava.util.function.Function
as an example) instead ofFunction<T, U>
And the jvm-based language can choose to understand this annotation (e.g. kotlin can understand
class C<@Covariant T>
asclass C<out T>
. This is convenient for developers to provide Kotlin-friendly APIs using pure Java.The text was updated successfully, but these errors were encountered: