-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Cannot disambiguate public overload from package-private #15821
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
Comments
In the OP example, it must be a My expectation was that accessibility does not determine overloading; candidate overloads must be applicable, but applicable does not entail accessible. I'm surprised the example compiles in Scala 2, and I'm surprised an ordinary object works in Scala 3. (Accessibility was added as a requirement for override eligibility, so maybe it was added for overload applicability.) The "doesn't use implicits" rule selects B in the first main:
I thought I witnessed differing results if the The point of that exercise was that people hint that Unqualified private is also ambiguous, even with main in a separate file:
|
It's also correct in the case of usage top-level definitions in a separate file which would be an idiomatic way of the same code in Scala 3 (package objects are going to be removed): /// foo.scala
package foo
def bar[F[_]]: Unit = ???
def bar[F[_]](x: Int): Unit = ???
private def bar[F[_]](x: Int)(implicit dummy: DummyImplicit): Unit = ??? // test.scala
@main def main = foo.bar(42) In case of removal |
Making a package object explicit re-computes the denotations of an overloaded method. So it should not be done after we have pruned down those denotations by an accessibility test. We now do it before checking accessibility. Fixes scala#15821
Making a package object explicit re-computes the denotations of an overloaded method. So it should not be done after we have pruned down those denotations by an accessibility test. We now do it before checking accessibility. Fixes scala#15821
Making a package object explicit re-computes the denotations of an overloaded method. So it should not be done after we have pruned down those denotations by an accessibility test. We now do it before checking accessibility. Fixes #15821
Making a package object explicit re-computes the denotations of an overloaded method. So it should not be done after we have pruned down those denotations by an accessibility test. We now do it before checking accessibility. Fixes scala#15821
Compiler version
3.2.1-RC1-bin-20220803-da2d44a-NIGHTLY
Minimized code
Output
Expectation
There should be no ambiguity because one of the "ambiguous" methods is package-private.
The text was updated successfully, but these errors were encountered: