Skip to content
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

CollectionConverters conflicts with FunctionConverters for Seq's #11519

joshlemer opened this issue May 6, 2019 · 2 comments


None yet
3 participants
Copy link

commented May 6, 2019

scala> import scala.jdk.CollectionConverters.Ops._
import scala.jdk.CollectionConverters.Ops._

scala> import scala.jdk.FunctionConverters.Ops._
import scala.jdk.FunctionConverters.Ops._

scala> List(1,2,3).asJava
       error: type mismatch;
        found   : List[Int]
        required: ?{def asJava: ?}
       Note that implicit conversions are not applicable because they are ambiguous:
        both method SeqHasAsJava in trait AsJavaExtensions of type [A](s: scala.collection.Seq[A])jdk.CollectionConverters.Ops.SeqHasAsJava[A]
        and method enrichAsJavaIntUnaryOperator in trait Priority0FunctionExtensions of type [A0](sf: A0 => Int)(implicit evA0: A0 =:= Int)scala.jdk.FunctionWrappers.RichFunction1AsIntUnaryOperator
        are possible conversion functions from List[Int] to ?{def asJava: ?}
       error: value asJava is not a member of List[Int]

This comment has been minimized.

Copy link

commented May 7, 2019

I don't have a good idea how to get around this... I don't see how we could make the collections asJava higher priority, as the two conversions are defined in separate objects.

If we had a combined scala.jdk.Converters for everything we could define priorities. It would get a little complex to think of all the combinations though.

So my recommendation would be to scope the imports, or use the explicit conversion methods when hitting an ambiguity.

@lrytz lrytz added this to the Backlog milestone May 7, 2019


This comment has been minimized.

Copy link

commented May 7, 2019

Perhaps the same setup that simulacrum uses to for extension methods of Semigroup/Monoid could work for Int => A/List[A]?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.