john.r.rose at oracle.com
Sat Dec 19 10:17:12 UTC 2015
On Dec 18, 2015, at 9:41 AM, Doug Lea <dl at cs.oswego.edu> wrote:
> Limiting value type V to only override equals(V x) seems to have
> the same simplifying impact on Collection.contains and others. Yes?
Maybe. But, Brian has written about edge cases where the
symmetry of Object.equals interacts badly with ad hoc code in collections.
Basically, if you write this.equals(x) you might expect to type x:(? extends V)
but if you write x.equals(this) you might expect to have to say x:(? super V).
After shaking things around, you give up and say x:any, which today is x:Object.
In the new world we can maybe get away with non-variant equals(V x),
and allow an escape hatch to the legacy world via boxing and the
old equals(Object x).
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the valhalla-spec-experts