Skip to content

Default arguments are no longer available for overriden method #16006

Closed
@WojciechMazur

Description

@WojciechMazur

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

Bisect points to d2eeef1

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.

Metadata

Metadata

Assignees

Labels

itype:bugregressionThis worked in a previous version but doesn't anymore

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions