Skip to content

Cannot disambiguate public overload from package-private #15821

Closed
@armanbilge

Description

@armanbilge

Compiler version

3.2.1-RC1-bin-20220803-da2d44a-NIGHTLY

Minimized code

//> using scala "3.2.1-RC1-bin-20220803-da2d44a-NIGHTLY"

@main def main =
  foo.bar(42)

package object foo {
  def bar[F[_]]: Unit = ???
  def bar[F[_]](x: Int): Unit = ???
  private[foo] def bar[F[_]](x: Int)(implicit dummy: DummyImplicit): Unit = ???
}

Output

[error] ./bug.scala:4:3: Ambiguous overload. The overloaded alternatives of method bar in package foo with types
[error]  [F[_$3]](x: Int)(implicit dummy: DummyImplicit): Unit
[error]  [F[_$2]](x: Int): Unit
[error] both match arguments ((42 : Int))
[error]   foo.bar(42)
[error]   ^^^^^^^

Expectation

There should be no ambiguity because one of the "ambiguous" methods is package-private.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions