JEP proposal: Improved variance for generic classes and interfaces
elias vasylenko
eliasvasylenko at gmail.com
Sun Oct 26 22:53:32 UTC 2014
Hi Dan,
Hope this proposal gains traction, I'm definitely an enthusiastic supporter.
(And apologies if this isn't appended to the appropriate thread, I just
joined the mailing list so I don't have the original email to reply to.)
Just a quick question/suggestion: it seems like a handy side-effect of the
proposed changes is the potential for relaxation of the limitation on
reimplementation of interfaces with different generic parametrisations, and
I'm wondering if you've considered this.
For example, it should be possible to allow something like this:
class Foo implements Predicate<Integer> {}
class Bar extends Foo implements Predicate<Number> {}
Since declaration-site variance guarantees compatibility of the overriding
parametrisation. Of course we can't technically override test(Integer) with
test(Number)... but from an outsiders perspective I don't see this as
incompatible with current language design philosophy... At any rate,
covariance should be more straightforward
I'm sure this would have come up if it hasn't already, but I couldn't find
any explicit mention of it.
Regards,
Elias Vasylenko
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20141026/5d986ae7/attachment.html>
More information about the compiler-dev
mailing list