Skip to content

Commit

Permalink
Merge pull request #10085 from som-snytt/issue/12623-case-copy-override
Browse files Browse the repository at this point in the history
Abstract parent copy does not suspend case copy
  • Loading branch information
lrytz committed Oct 31, 2022
2 parents a333a0f + ddde023 commit 5790494
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/compiler/scala/tools/nsc/typechecker/Namers.scala
Expand Up @@ -1230,7 +1230,7 @@ trait Namers extends MethodSynthesis {
val modClass = companionSymbolOf(clazz, context).moduleClass
modClass.attachments.get[ClassForCaseCompanionAttachment] foreach { cma =>
val cdef = cma.caseClass
def hasCopy = (decls containsName nme.copy) || parents.exists(_.member(nme.copy).exists)
def hasCopy = decls.containsName(nme.copy) || parents.exists { p => val ov = p.member(nme.copy); ov.exists && !ov.isDeferred }

// scala/bug#5956 needs (cdef.symbol == clazz): there can be multiple class symbols with the same name
if (cdef.symbol == clazz && !hasCopy)
Expand Down
19 changes: 19 additions & 0 deletions test/files/pos/t12623.scala
@@ -0,0 +1,19 @@

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]

/*
was:
t12623.scala:9: error: class C needs to be abstract.
Missing implementation for member of trait MapI:
def copy(i: Int, s: String): C = ???
case class C(i: Int, s: String) extends MapI[C]
^
*/

0 comments on commit 5790494

Please sign in to comment.