Skip to content

Ambiguously overloaded methods fail to error when assigned to a val #18294

Closed as not planned
@jchyb

Description

@jchyb

Compiler version

main (97677cc), 3.3.0 and likely any previous version

Minimized code

def f(s: Int): Unit = println("a")
def f: Int => Unit = _ => println("b")

@main def Test =
  val test: Int => Unit = f
  test(0)
  // f(0) // this errors out as expected

Output

Compiles, and when run prints "a".

Expectation

Should error out with an Ambiguous Overload error, like using f directly does.

Additional comment

I found this when working on #18286, and I know that resolveOverloaded1 method here can affect which f is being chosen - so the issue likely lies somewhere there.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions