Skip to content

Change in behavior in 2.13 for implicit overloads #11662

Open
@travisbrown

Description

This code compiles on Scala 2.10, 2.11, and 2.12:

class Foo(xs: List[_])
object Foo {
  def make(xs: List[_]): Foo = new Foo(xs)
  implicit def make[A](xs: List[A])(implicit X: DummyImplicit): Foo = new Foo(xs)
}

List(""): Foo

…but the last line fails to compile on 2.13.0:

scala> List(""): Foo
           ^
       error: ambiguous reference to overloaded definition,
       both method make in object Foo of type [A](xs: List[A])(implicit X: DummyImplicit)Foo
       and  method make in object Foo of type (xs: List[_])Foo
       match argument types (List[String]) and expected result type Foo

I'm about 80% convinced the bug is on the 2.10, 2.11, 2.12 side of things, and that the 2.13.0 behavior is correct, but I'm opening this issue for the 20% where I'm wrong about that.

For what it's worth I ran into this issue in real code in the Sangria tests.

Metadata

Assignees

No one assigned

    Labels

    fixed in Scala 3This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/)overloadingregression

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions