Closed
Description
Compiler version
3.0.2
Minimized code
class Base
class A extends Base
class B extends Base
trait T[X]
given T[A]()
def f[X <: Base](ins: X)(using T[X]) = "with T"
def f[X <: Base](ins: X) = "without T"
@main def m = f(A())
Output
Ambiguous overload. The overloaded alternatives of method f with types
[X <: Base](ins: X)(using x$2: T[X]): String
[X <: Base](ins: X): String
both match arguments (A)
f(A())
Expectation
To work similar to the regular case:
def f[X <: Base](ins: X)(t: T[X]) = "with T"
def f[X <: Base](ins: X) = "without T"
I first suspected this to be an issue with the implicit being optional in that case, but the following doesn't work either:
def f[X <: Base](ins: X)(using T[X]) = "with T"
def f[X <: Base](ins: X)(using NotGiven[T[X]]) = "without T"