diff options
author | Lukas Rytz <lukas.rytz@epfl.ch> | 2012-07-13 12:31:14 +0200 |
---|---|---|
committer | Lukas Rytz <lukas.rytz@epfl.ch> | 2012-07-13 14:22:27 +0200 |
commit | 2c5890b3a7aa227643fde86ba72820a8016bc453 (patch) | |
tree | db02fc3ceb9fbd7112fe74cc47df24900a05d0df /src | |
parent | 758f0a7ac5366c9748739032383456b6e7727d37 (diff) | |
download | scala-2c5890b3a7aa227643fde86ba72820a8016bc453.tar.gz scala-2c5890b3a7aa227643fde86ba72820a8016bc453.tar.bz2 scala-2c5890b3a7aa227643fde86ba72820a8016bc453.zip |
SI-5956 trigger copy generation with correct namer
the call to `addCopyMethod` passes `templateNamer`, which is supposed to be the
namer of the case class template. with two classes of the same name, `addCopyMethod`
was triggered in the wrong template.
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Namers.scala | 8 |
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) |