-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Java interop: no more static 'empty' for collections #11509
Comments
We could slap That would also give me |
I'm not familiar with changes in for comprehensions in Dotty so I'll leave that to @adriaanm. But if they require this method then the change is probably inevitable. You can always get the "static" parts in Java via |
I think the change hasn't happened yet (or I didn't notice) but it's in pursuit of scala/scala3#2573 as I understand it. scala/scala-dev#607 mentions that we could wait for 2.14, but in scala/scala#7929 @adriaanm expressed a desire to make no backwards-incompatible changes in 2.14. So depending on Dotty's willingness to run off of 2.14.x, (or merge scala/scala3#5813), maybe this could just be backed out. (Unless the |
Scheduling for RC2 in case we want to revert the |
Or add a static |
Also to clarify, dotty doesn't care about |
I like it, but does that mean we'd have two ways of creating the same |
evil suggestion: make it |
Affects also play (scalacommunitybuild/playframework@80657d0), akka-http (scalacommunitybuild/akka-http@6d03ee4) |
I think it's quite likely an improved for-comprehension desugaring would avoid |
Or in |
We're considering removing the |
After trying to remove The version in 2.13.x before scala/scala@a864ae0 was not ideal, either. Fixing those types and deprecating the existing methods would be an option but they are used pervasively in the collection implementations. We need at least a protected version of this method so we'd have to add it under a new name and deprecate Maybe we are just missing the right abstraction. We have different polymorphic factories in collection instances but there is no monomorphic |
Ok, I’m glad you did the due diligence. Let’s leave this ticket open for some alternate fix. |
Do you mean having to go via |
Yes, technically we could spec the desugaring to use a sequence of two
method calls (e.g., too.companion.empty when you need to signal failure).
Since the desugaring should be more general than our collections, it seems
a bit too ad-hoc, though. It should be grounded in some more abstract
theory, imo.
…On Tue, 14 May 2019 at 17:46, Dale Wijnand ***@***.***> wrote:
But it could be difficult to add this extra layer of indirection without
negatively affecting performance.
Do you mean having to go via .iterableFactory, or something else?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#11509?email_source=notifications&email_token=AAAWHS37F5D5OFXK4TN7YULPVLNEHA5CNFSM4HJJR552YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODVL5GUQ#issuecomment-492294994>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAAWHSZQSN5RF4S2P7JVQ6TPVLNEHANCNFSM4HJJR55Q>
.
|
Could you spec it as |
That seems cleaner, yes. The larger question, though, is: what should the spec be in the first place :-) I think we could consider working on this in 2.14 if there's demand. Will keep that in mind when I open the roadmap ticket for 2.14, as soon as 2.13.0 final is tagged :) |
If we remove it now, and Dotty wants to play with |
True, but there are other reasons to keep it: #11509 (comment) |
Related: scala/scala-dev#573 Another hack we could do is adding an |
OK, the specific factory doesn't really work. |
As a side-note, why do some collections have a package-private |
To work around scala/bug#11509
|
Probably and oversight when the old code was ported from 2.12. These methods are not used for anything. |
* Add ByteString.emptyByteString to Java API To work around scala/bug#11509 * Add note to 2.6 migration document
Moving to 2.14 as we can't do anything (binary incompatible) compatible in the 2.13 series. |
scala/scala@a864ae0 (added between 2.13.0-M5 and 2.13.0-RC1) introduces a
def empty()
onscala.collection.Iterable
.Many (immutable) implementations of
Iterable
, such asscala.collection.immutable.List
, have a companion object with aval empty
. On 2.13.0-M5 and earlier, Java users could use theList.empty()
static forwarder to get the emptyList
instance. From 2.13.0-RC1, this static forwarder no longer exists, because theList
class itself now has a non-staticempty()
method inherited fromIterable
.According to the commit message the change was intended to "facilitate the switch to dotty's for comprehensions" - I don't know anything about that, so it might well be that the change is inevitable or worth it for that reason - I just wanted to flag this consequence that might not have been intentional.
What would be the new way for a Java user to get easy access to an empty instance of such an immutable collection?
The text was updated successfully, but these errors were encountered: