summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAdriaan Moors <adriaan.moors@epfl.ch>2012-07-16 04:42:40 -0700
committerAdriaan Moors <adriaan.moors@epfl.ch>2012-07-16 04:42:40 -0700
commit6d0d5054faab2c0d2d4c112def6d58f7965ad69b (patch)
treeab5a75c5139c8260b9a576e09604cc0a1eb0008a /src
parent1cb4ed8484f147830e90fb881a98b3b58edcf1c9 (diff)
parent2c5890b3a7aa227643fde86ba72820a8016bc453 (diff)
downloadscala-6d0d5054faab2c0d2d4c112def6d58f7965ad69b.tar.gz
scala-6d0d5054faab2c0d2d4c112def6d58f7965ad69b.tar.bz2
scala-6d0d5054faab2c0d2d4c112def6d58f7965ad69b.zip
Merge pull request #897 from lrytz/t5956
SI-5956 trigger copy generation with correct namer
Diffstat (limited to 'src')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Namers.scala8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Namers.scala b/src/compiler/scala/tools/nsc/typechecker/Namers.scala
index 9580cd5676..48fd6ba928 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Namers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Namers.scala
@@ -835,13 +835,15 @@ trait Namers extends MethodSynthesis {
// add the copy method to case classes; this needs to be done here, not in SyntheticMethods, because
// the namer phase must traverse this copy method to create default getters for its parameters.
- // here, clazz is the ClassSymbol of the case class (not the module).
- if (clazz.isClass && !clazz.hasModuleFlag) {
+ // here, clazz is the ClassSymbol of the case class (not the module). (!clazz.hasModuleFlag) excludes
+ // the moduleClass symbol of the companion object when the companion is a "case object".
+ if (clazz.isCaseClass && !clazz.hasModuleFlag) {
val modClass = companionSymbolOf(clazz, context).moduleClass
modClass.attachments.get[ClassForCaseCompanionAttachment] foreach { cma =>
val cdef = cma.caseClass
def hasCopy(decls: Scope) = (decls lookup nme.copy) != NoSymbol
- if (cdef.mods.isCase && !hasCopy(decls) &&
+ // SI-5956 needs (cdef.symbol == clazz): there can be multiple class symbols with the same name
+ if (cdef.symbol == clazz && !hasCopy(decls) &&
!parents.exists(p => hasCopy(p.typeSymbol.info.decls)) &&
!parents.flatMap(_.baseClasses).distinct.exists(bc => hasCopy(bc.info.decls)))
addCopyMethod(cdef, templateNamer)