Skip to content

Rules for 2nd constructor differ from Scala2 #6368

Closed
@liufengyun

Description

@liufengyun

Dotty accepts the first two constructors, while they are rejected by Scala2:

class A(x: Int, y: Int) {
  def this() = {          // only Dotty
    this()
  }

  def this(x: Long) = {   // only Dotty
    this(x.toInt)
  }

  def this(a: Int) = {   // both Dotty & Scala2
    this(a, a)
  }
}

A related question: do we allow 2nd constructor for traits?

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