Open
Description
Compiler version
3.6.3
Minimized code
object X:
extension (s: String) def huh = s.reverse
object Y:
def f(): String =
import X.huh
val huh = "huh".huh
huh
@main def test() = println:
Y.f()
Output
huh
Expectation
DNC as with
val huh = huh("huh")
because the extension fails the visible under a simple name
test.
The doc says
If m is imported by several imports which are all on the nesting level, try each import as an extension method instead of failing with an ambiguity.
That is, relaxed imports disambiguates among possible imports, not between an import and a local definition.
If the weird behavior is intended, then the doc should be more explicit about this use case.
where the diff looks unintended:
Imports are not relaxed with respect to local extension methods:
object Z:
import X.huh
extension (i: Int) def huh = i.toString.reverse
val huh = "huh".huh // Required: Int
def f(): String = huh