bug icon indicating copy to clipboard operation
bug copied to clipboard

case class synthetic method generation when abstract method declaration is present

Open peter-empen opened this issue 3 years ago • 1 comments

Reproduction steps

Scala version: 2.13.8

trait MapI[C] {
  def i: Int
  def s: String
  def copy(i: Int = this.i, s: String = this.s): C
  def mapI(i: Int): C = copy(i)
}

case class C(i: Int, s: String) extends MapI[C]

Problem

The compiler reports "class C needs to be abstract. Missing implementation for: def copy(i: Int, s: String): C inherited from trait MapI".

Expectation

I'd appreciate the compiler not stopping synthetic method generation if an abstract method declaration is present. This way one would not need to implement mapI in every case class. I also checked Scala 3.1.2 which works fine.

See also

https://contributors.scala-lang.org/t/continue-with-case-class-synthetic-method-generation-when-abstract-method-declaration-is-present/5826

peter-empen avatar Jul 23 '22 07:07 peter-empen

A "has PR" label is strictly redundant with Github's tag "May be fixed by".

som-snytt avatar Sep 19 '22 13:09 som-snytt