dotty-feature-requests
dotty-feature-requests copied to clipboard
Several imports of the same name should form an overloaded definition
Minimized code + Output
object A:
def f(s: Int) = s
object B:
def f(s: String) = s
import A.f
import B.f
println(f(1))
^
Reference to f is ambiguous,
it is both imported by name by import A.f
and imported by name subsequently by import B.f
Expectation
The compiler should behave the same as in the code below, that is, as if the definitions above is overloaded.
object C:
def f(s: Int) = s
def f(s: String) = s
import C.f
println(f(1))
//1
See https://docs.oracle.com/javase/specs/jls/se15/html/jls-15.html#jls-15.12.1 for how member methods that are imported by static-import declarations are processed in Java.
The corresponding (ambiguity) error message has been fixed in lampepfl/dotty#9834, but this did not change the overloading behavior.
This a feature request, not a bug.