Skip to content
This repository has been archived by the owner on Jun 5, 2023. It is now read-only.

Several imports of the same name should form an overloaded definition #143

Open
rjolly opened this issue Oct 5, 2020 · 2 comments
Open

Comments

@rjolly
Copy link

rjolly commented Oct 5, 2020

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.

@b-studios
Copy link

The corresponding (ambiguity) error message has been fixed in scala/scala3#9834, but this did not change the overloading behavior.

@smarter
Copy link
Member

smarter commented Oct 5, 2020

This a feature request, not a bug.

@smarter smarter removed their assignment Oct 5, 2020
@smarter smarter transferred this issue from scala/scala3 Oct 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants