Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Abstract parent copy does not suspend case copy #10085

Merged
merged 1 commit into from Oct 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/compiler/scala/tools/nsc/typechecker/Namers.scala
Expand Up @@ -1210,7 +1210,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]
^
*/