Closed
Description
minimized code
trait Foo {
def g(f: Int => Int): Int = 1
def g(f: String => String): String = "2"
}
@main def Test =
val m: Foo = new Foo {}
m.g(a => 1)
-- [E051] Reference Error: /Users/kmetiuk/Projects/scala3/pg/sandbox/iss4.scala:8:4
8 | m.g(a => 1)
| ^^^
|Ambiguous overload. The overloaded alternatives of method g in trait Foo with types
| (f: String => String): String
| (f: Int => Int): Int
|both match arguments (? => ?)
It works in Scala 2. If you explicitly specify the type of the lambda argument, m.g((x: Int) => 1)
, it also works.
expectation
The code should correctly resolve the overload alternative.