Skip to content

Bad Interaction between constructor overloading and default parameters #3171

Closed
@allanrenucci

Description

@allanrenucci

The following code snippet fails to compile with Dotty

object Test {
  class C(x: Int, y: Int) {
    def this(x: Int = 1)(y: String) =
      this(x, y.toInt)
  }
  
  def test: Unit = {
    new C()("1")
  }
}
-- Error: tests/allan/Test.scala:8:8 -------------------------------------------
8 |    new C()("1")
  |        ^
  |missing argument for parameter x of constructor C: (x: Int)(y: String): Test.C

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