scala3 icon indicating copy to clipboard operation
scala3 copied to clipboard

Default arguments are no longer available for overriden method

Open WojciechMazur opened this issue 2 years ago • 1 comments

Regression found in the Open CB #5274 for scalanlp/breeze

Bisect points to https://github.com/lampepfl/dotty/commit/d2eeef1f9a84ebbd36f53740aa997dd77d438281

Compiler version

Scala 3.2.2-RC1-bin-20220907-a503b7a-NIGHTLY

Minimized code

class X: 
  def toString(maxLines: Int = 10, maxWidth: Int = 10): String = (maxLines -> maxWidth).toString

class Foo extends X:
  override def toString(maxLines: Int, maxWidth: Int): String = s"overriden ($maxLines, $maxWidth)"
  override def toString(): String = toString(maxLines = 3)


@main def Test = {
  println(Foo().toString())
}

Output

In Scala 3.2.1-RC1

Compiled project (Scala 3.2.1-RC1, JVM)
overriden (3, 10)

In nightly

Compiling project (Scala 3.2.2-RC1-bin-20220907-a503b7a-NIGHTLY, JVM)
[error] ./test.scala:7:37: None of the overloaded alternatives of method toString in class Foo with types
[error]  (): String
[error]  (maxLines: Int, maxWidth: Int): String
[error] match arguments ((3 : Int))
[error]   override def toString(): String = toString(maxLines = 3)
[error]   

Expectation

Should be decided if behaviour follows the specification and fixed.

WojciechMazur avatar Sep 09 '22 09:09 WojciechMazur

That's not intentional. It's probably caused by #15962. I am on it.

odersky avatar Sep 09 '22 09:09 odersky