SI-9684 Deprecate JavaConversions#5109
Conversation
7f3fb52 to
cea6116
Compare
|
Review by @som-snytt I squashed all your commits into one. Compared to the latest commit in #5064 the following has changed:
|
|
There's one problem created by this PR. Now The Unfortunately, the names of these explicit converter methods are exactly the same as the names of the implicit converter methods in the deprecated What happens here ( So basically when somebody has both imports, the implicit conversions will stop working after this PR. There will not be a deprecation warning for The alternative would be to rename all implicit conversion methods in |
| * via the Java interface and vice versa. | ||
| * | ||
| * If the Java `Iterator` was previously obtained from an implicit or | ||
| * explicit call of `asIterator(scala.collection.Iterator)` then the |
There was a problem hiding this comment.
I didn't update the method names referred to by the implicits here.
|
Thanks for picking this up. Otherwise, it's kind of thankless. I had another pass to make on the old PR. I didn't notice that consequence of the naming conflict you point out. I don't have a clever workaround. I would definitely go with not supporting wildcard imports from both. They are presented as alternatives, and no examples show imports from both. If the issue were serious enough, the "new" explicit methods could be renamed |
|
Actually, the workaround is to add implicits back to Actually it has to be a lower-priority implicit, to allow implicit selection. |
|
Yeah, tried it out: Making the new method more specific makes it easier to type in. |
|
@som-snytt i pushed two more commits to address your feedback. |
|
Your solution of renaming the implicits is different from what I proposed. Does it work? It's too late in afternoon here for me to know without trying. I thought importing |
|
It seems to work, here's the test: 75b8875#diff-9acf6de82fd57ddd8dc4c907a07bfe72 I liked your idea, but then realized that renaming the implicits and providing non-implicit methods with the old name also works, and it seems simpler. |
|
Renaming implicits is itself not source compatible: someone might have imported one specifically, rather than via a wildcard. |
|
ah, true.. i'll give @som-snytt's idea try then. |
|
Now I see what you had done. I was on minimal sleep and had to get the daughter to Met Opera at the cinema, Sondra Radvanovsky as Q.E. 1. What a performance. If the daughter grows up to be like either Radvanovsky or Elizabeth, I'd be OK with it. Modulo beheading your ex. I didn't actually sleep in Act 1, but I may have rested my eyes. |
|
I'd still like a motivating use case for |
Would this mean that |
|
I pushed another commit that adds the higher-priority implicits with non-clashing names to JavaConversions. |
|
Backquotes are totally the boss. You're right about The use case for |
Implicit conversions are now in package convert as ImplicitConversions, ImplicitConversionsToScala and ImplicitConversionsToJava. Deprecated WrapAsJava, WrapAsScala and the values in package object. Improve documentation.
Provide higher-priority implicit conversion methods whose names don't clash with methods in JavaConverters. This allows implicit conversions to work when importing both JavaConverters._ and JavaConversions._.
|
rebased due to merge conflict. @som-snytt lgty? |
|
LGTM I see you were cleverly efficient with some more doc updates. |
|
/rebuild 3bf207b |
|
Have we considered the case where Java code uses the methods in |
|
@ijuma The doc says "Alternatively, the conversion methods have descriptive names and can be invoked explicitly." So now they are available on JavaConverters. That wasn't the case previously, only in order to make the implicits work. lrytz deals with the naming starting at #5109 (comment) |
Implicit conversions are now in package convert as ImplicitConversions,
ImplicitConversionsToScala and ImplicitConversionsToJava.
Deprecated WrapAsJava, WrapAsScala and the values in package object.
Improve documentation.