Skip to content

Method call fails for overloaded methods with default parameters #12679

Closed
@danicheg

Description

@danicheg

Compiler version

3.0.0

Minimized code

object Foo extends App {
  def foo[F[_]](qux: String, quux: String = ""): F[Unit] = ???

  def foo[F[_]](qux: Boolean): F[Unit] = ???

  def example[F[_]](maybeQux: Option[String], bool: Boolean) =
    maybeQux.fold(foo[F](bool))(foo[F](_))
}

https://scastie.scala-lang.org/LnY1kBvlQs2zclBzaeA0Vg

Output

7 |    maybeQux.fold(foo[F](bool))(foo[F](_))
  |                                ^^^
  |None of the overloaded alternatives of method foo in object Foo with types
  | [F[_$2]](qux: Boolean): F[Unit]
  | [F[_$1]](qux: String, quux: String): F[Unit]
  |match type arguments [F] and arguments ((_$4 : String))

Expectation

That works in Scala 2 (both 2.12.13 and 2.13.6).

Metadata

Metadata

Assignees

No one assigned

    Labels

    backlogNo work planned on this by the core team for the time being.itype:bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions