Closed
Description
minimized code
object Overloads {
def foo[V](x: Int = 0, y: Int = 0, z: Int = 0): Nothing = ???
def foo[V](x: Int, y: Int): Nothing = ???
def foo[V](x: Int): Nothing = ???
foo(1)
}
expectation
This compiles in Scala 2.13.0, but we have an error in Dotty (0.18.x on master), this would be an issue for porting Fastparse 2. It compiles in Dotty if we remove the type parameters on foo.
-- [E051] Reference Error: local/Overloads.scala:9:2 ---------------------------
9 | foo(1)
| ^^^
|Ambiguous overload. The overloaded alternatives of method foo in object Overloads with types
| [V](x: Int): Nothing
| [V](x: Int, y: Int): Nothing
| [V](x: Int, y: Int, z: Int): Nothing
|all match arguments (Int(1))
Explanation
===========
There are 3 methods that could be referenced as the compiler knows too little
about the expected type.
You may specify the expected type e.g. by
- assigning it to a value with a specified type, or
- adding a type ascription as in instance.myMethod: String => Int