diff options
author | Lukas Rytz <lukas.rytz@epfl.ch> | 2010-02-26 12:49:02 +0000 |
---|---|---|
committer | Lukas Rytz <lukas.rytz@epfl.ch> | 2010-02-26 12:49:02 +0000 |
commit | cda9718a21ca02d7d13efe7b07f4d4e0c5697171 (patch) | |
tree | 8a6d2e598d0a71e1666ba4ef2bcb4a50631cc3a4 /src/compiler/scala/tools/nsc/typechecker/Namers.scala | |
parent | 00814d33caf1b321ccc24b85ff69f146ea1acdaa (diff) | |
download | scala-cda9718a21ca02d7d13efe7b07f4d4e0c5697171.tar.gz scala-cda9718a21ca02d7d13efe7b07f4d4e0c5697171.tar.bz2 scala-cda9718a21ca02d7d13efe7b07f4d4e0c5697171.zip |
close #3071.
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker/Namers.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Namers.scala | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Namers.scala b/src/compiler/scala/tools/nsc/typechecker/Namers.scala index c515a1db77..3883031d08 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Namers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Namers.scala @@ -310,18 +310,21 @@ trait Namers { self: Analyzer => ltype = new PolyTypeCompleter(tparams, ltype, tree, sym, context) //@M if (sym.isTerm) skolemize(tparams) } - def copyIsSynthetic() = sym.owner.info.member(nme.copy).hasFlag(SYNTHETIC) - if (sym.name == nme.copy && sym.hasFlag(SYNTHETIC) || - sym.name.startsWith(nme.copy + "$default$") && copyIsSynthetic()){ - // the 'copy' method of case classes needs a special type completer to make bug0054.scala (and others) - // work. the copy method has to take exactly the same parameter types as the primary constructor. + + if (sym.name == nme.copy || sym.name.startsWith(nme.copy + "$default$")) { + // it could be a compiler-generated copy method or one of its default getters setInfo(sym)(mkTypeCompleter(tree)(copySym => { - val constrType = copySym.owner.primaryConstructor.tpe - val subst = new SubstSymMap(copySym.owner.typeParams, tparams map (_.symbol)) - for ((params, cparams) <- tree.asInstanceOf[DefDef].vparamss.zip(constrType.paramss); - (param, cparam) <- params.zip(cparams)) { - // need to clone the type cparam.tpe??? problem is: we don't have the new owner yet (the new param symbol) - param.tpt.setType(subst(cparam.tpe)) + def copyIsSynthetic() = sym.owner.info.member(nme.copy).hasFlag(SYNTHETIC) + if (sym.hasFlag(SYNTHETIC) && (!sym.hasFlag(DEFAULTPARAM) || copyIsSynthetic())) { + // the 'copy' method of case classes needs a special type completer to make bug0054.scala (and others) + // work. the copy method has to take exactly the same parameter types as the primary constructor. + val constrType = copySym.owner.primaryConstructor.tpe + val subst = new SubstSymMap(copySym.owner.typeParams, tparams map (_.symbol)) + for ((params, cparams) <- tree.asInstanceOf[DefDef].vparamss.zip(constrType.paramss); + (param, cparam) <- params.zip(cparams)) { + // need to clone the type cparam.tpe??? problem is: we don't have the new owner yet (the new param symbol) + param.tpt.setType(subst(cparam.tpe)) + } } ltype.complete(sym) })) |