Why is Map.keys
returning a Collection
and not a Set
?
#6063
Comments
Fixed. |
Thanks ! |
This fix has now been moved to the 6063 branch. |
This looks like a non-backwards-compatible change – not for consumers, but for implementers of the interface. Whoever did refine this method (e.g. because there was a more efficient implementation) declaring the return type as I don't know enough about binary compatibility to be sure, but from afar it looks like it is compatible neither for consumers nor for implementors on the JVM (because the erased return type is part of the signature). |
So, given the version number upgrade, I would advocate that we put this on the table for 1.3.0. It's a break to BC, but one that I still insist is pretty minor. WDYT? |
My only thought would be that I was hoping we'd get more bang for the buck with the next compatibility breaking release. I know there are other things that we probably don't have time for. Regarding the Compatibility
But also:
And even:
The second incompatibility is slightly surprising, since If we call the old binary below from within a new runtime, we get: shared void callKeys(Map<Anything,Anything> map) {
Correspondence<Nothing> corr = map;
noop(corr.keys); // ok
noop(map.keys); // java.lang.NoSuchMethodError: ceylon.language.Map.getKeys()Lceylon/language/Collection;
} and from the above, it follows that old binaries like this fail too: noop(HashMap { 1 -> 1 }.keys); // java.lang.NoSuchMethodError: ceylon.language.Map.getKeys()Lceylon/language/Collection; Finally, more surprisingly, even if the old binary were to first cast to Correspondence<Nothing> corr = HashMap { 1 -> 1 };
noop(corr.keys); // java.lang.NoSuchMethodError: ceylon.language.Map$impl.getKeys()Lceylon/language/Collection; The reason is that the old public final class Map$impl<Key, Item> implements .java.io.Serializable { ... } TL;DR: Pretty much anything involving |
@jvasileff paints a bleak picture for such a seemingly small change. Personally I don't think the breakage is worth the relatively small advantage the change brings. |
Alright, fine, so not for 1.3.0. :-( |
Done, finally. |
No description provided.
The text was updated successfully, but these errors were encountered: