summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Namers.scala5
-rw-r--r--test/files/run/names-defaults.scala4
2 files changed, 6 insertions, 3 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Namers.scala b/src/compiler/scala/tools/nsc/typechecker/Namers.scala
index 1b2fde4f4a..dd166b3086 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Namers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Namers.scala
@@ -307,8 +307,9 @@ trait Namers { self: Analyzer =>
ltype = new PolyTypeCompleter(tparams, ltype, tree, sym, context) //@M
if (sym.isTerm) skolemize(tparams)
}
- if ((sym.name == nme.copy || sym.name.startsWith(nme.copy + "$default$")) &&
- sym.hasFlag(SYNTHETIC)) {
+ 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.
setInfo(sym)(mkTypeCompleter(tree)(copySym => {
diff --git a/test/files/run/names-defaults.scala b/test/files/run/names-defaults.scala
index 1235869db7..1f92436628 100644
--- a/test/files/run/names-defaults.scala
+++ b/test/files/run/names-defaults.scala
@@ -257,9 +257,11 @@ object Test extends Application {
spawn(b = { val ttt = 1; ttt }, a = 0)
}
- // # 2382
+ // #2382
class A2382[+T](x: T => Int) { def foo(a: T => Int = x) = 0 }
+ // #2390
+ case class A2390[T](x: Int) { def copy(a: Int)(b: Int = 0) = 0 }
// DEFINITIONS
def test1(a: Int, b: String) = println(a +": "+ b)