-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Organize JDK converters: extension methods for Scala in scala.jdk, explicit converters for Java in jdk.javaapi #7987
Conversation
using package name (in addition to Scaladocs)?I think there are different use cases targeting two different audiences.
The situation is similar to Akka HTTP having both Scala and Java DSL for Routing DSL for example. In case of Akka HTTP, the APIs are given different packages I think the current make "Scala DSL" the primaryAs opposed to This is to make it more consistent with other DSLs name for Java DSLThe name of Java DSL package should be obvious that it's targeting Java programmers. Like "a la carte" importIf we want to still provide "a la carte" DSL, such as // scala
import scala.jdk.FunctionConverters._
// java
import scala.jdk.javadsl.FunctionConverters._ In general though I think we should point people to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a comment on the overall "feel".
I'm not in favor of this, I think it's a good thing to force people to be explicit and import conversions for the kind of types that they want to convert (options, functions, collections, streams, futures).
That looks fine to me, except for the
As I said above, -1 from me on this one. |
Collection gets a lumping of
|
c9ab1fa
to
3a43b82
Compare
3a43b82
to
a89783a
Compare
OK, I moved the stuff around :-)
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Reorganize JDK converters:
import scala.jkd.XConverters._
now brings in extension methods, intended for Scala code. `scala.jdk.javaapi.XConverters has explicit conversion methods, intended for Java code.Those explicit conversion methods (in
javaapi
) that refer to a primitive type, e.g.,def toJavaOptionalDouble(o: Option[jl.Double]): OptionalDouble
, now use the Java box types instead of the Scala primitive types. The reason is the generic signature.Option[Double]
in Scala has generic signatureOption[Object]
(scala/bug#4214), which makes the explicit converter methods really annoying to use in Java code. But that's the main goal of having these methods - for Scala code, we recommend the extension methods defined in thescala.jdk
objects.So for 2.13.0, as it's too late to change the compiler, we use the java primitive box types directly in the signatures.
This makes the explicit conversion methods hard to use in Scala, but the Scaladocs tell people to go for the extension methods.
We never had this issue with
collection.JavaConverters
(nowjdk.CollectionConverters
) because there are no signatures with primitives in there.