Skip to content

Compiler does not error when duplicate methods exist in generated bytecode #19274

Open
@kubukoz

Description

@kubukoz

Compiler version

3.3.1

Minimized code

//> using scala 3.3.1

case class StaticBinding(v: String) {
  private def copy$default$1(): String = ???
}

object Demo extends App {
  val b = StaticBinding("test")
  println(b)
}

Output

Error: Unable to initialize main class Demo
Caused by: java.lang.ClassFormatError: Duplicate method name "copy$default$1" with signature "()Ljava.lang.String;" in class file StaticBinding
Program exited with return code 1.

Expectation

Compilation failure (same as in 2.13.11):

[error] ./main.scala:3:26
[error] double definition:
[error] private def copy$default$1(): String at line 4 and
[error] def copy$default$1: String at line 3
[error] have same type
[error] case class StaticBinding(v: String) {
[error]                          ^
Error compiling project (Scala 2.13.11, JVM (17))

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions