String.exceptLast should be refined to return String
Closed this issue · 13 comments
[@luolong] This is bound to raise some eyebrows:
String string = ...
{Character*} exceptLast = string.exceptLast;
After that I can't use any String
methods, which is counter intuitive...
[Migrated from ceylon/ceylon.language#763]
[@gavinking] I'm happy to refine exceptLast
on List
, String
, and Sequential
, just like we do with rest
.
[@gavinking] Send me a patch.
Done.
Re-opening for further consideration.
In a library I'm currently writing, I got the following after compiling on 1.3.2 and running on 1.3.3:
Exception in thread "main" java.lang.NoSuchMethodError: ceylon.language.String.getExceptLast(Ljava/lang/String;)Lceylon/language/Iterable;
This is similar to, although probably not exactly the same as, #6063
Grrrr. So I guess we change the return type back to Iterable
and hack the backend to add a typecast. PITA.
This is such utter crap though: quite clearly, narrowing a return type should be a binary-compatible change, wtf!
Oh, wait, I see what's going on: it's the static method which has changed from returning Iterable
to returning java.lang.String
(not Ceylon String
). That is a binary-incompatible change indeed. Shit.
Ah, makes sense. Although really for static
methods I think any narrowing of the raw return type would break BC since statics don't have refined methods to let the compiler know what bridge methods to generate.
@FroMage I still need to figure out what to do about this one before the release.
Ditto for List.exceptLast
.
I've reverted the revert.
Done.