Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scala 2 less generous than 3 on import ambiguity #13066

Open
som-snytt opened this issue Dec 9, 2024 · 0 comments
Open

Scala 2 less generous than 3 on import ambiguity #13066

som-snytt opened this issue Dec 9, 2024 · 0 comments

Comments

@som-snytt
Copy link

Reproduction steps

Scala version: 2.13.15

package testsamepackageimport {
  package p {
    class C
  }

  package p {
    package q {
      import p._ // warn
      class U {
        def f = new C
      }
    }
  }
}

errors

pkg-import.scala:11: error: reference to C is ambiguous;
it is both defined in package p and imported subsequently by
import p._
        def f = new C
                    ^
pkg-import.scala:9: warning: Unused import
      import p._ // warn
               ^
1 warning
1 error

but does not error at the same nesting level

package testsamepackageimport {
  package p {
    class C
  }

  package p {
    import p._ // warn
    package q {
      class U {
        def f = new C
      }
    }
  }
}

Problem

It should only error if the competing import and definition resolve to different symbols.

The import is unused but not erroneous.

Scala 3 does not error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant