Skip to content

manually defining _N methods in case class can produce Double definition error #9068

Closed
@Rich2

Description

@Rich2
case class MyClass(v1: Int, v2: Int, v3: Int) extends Product3[Int, Int, Int]
{ def _1: Int = v1
  def _2: Int = v2
  def _3: Int = v3
}
error] -- [E120] Naming Error: /Common/s2dotty/src/P4.scala:4:6 -----------------------
[error] 4 |{ def _1: Int = v1
[error]   |      ^
[error]   |      Double definition:
[error]   |      def _1: => Int in class MyClass at line 3 and
[error]   |      def _1: => Int in class MyClass at line 4
[error]   |      have the same type after erasure.

To be able to compile to Scala 2 and dotty without error. I'm guessing Dotty is automatically creating the _n properties. This would be great except those properties have to be defined explicitly for code cross compiling to 2.13.

Simple project to show this here

Metadata

Metadata

Assignees

Labels

area:desugarDesugaring happens after parsing but before typing, see desugar.scalaitype:bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions