Skip to content

Overloading resolution failed when overloaded val and def have the same number of parameters #4854

@Medowhill

Description

@Medowhill
class C {
  def f(x: Int): Unit = ()
  val f: String => Unit = s => ()
  f("a")
}

The above code is compiled in scalac but results the following error in dotc.

-- [E007] Type Mismatch Error: ../B.scala:4:4 ----------------------------------
4 |  f("a")
  |    ^^^
  |    found:    String("a")
  |    required: Int
  |
one error found

Is it an intended semantics of dotty?

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