diff options
author | Lukas Rytz <lukas.rytz@epfl.ch> | 2010-04-09 09:51:00 +0000 |
---|---|---|
committer | Lukas Rytz <lukas.rytz@epfl.ch> | 2010-04-09 09:51:00 +0000 |
commit | 3cc8af6179ac7b1778c19d96bfacd01120407d26 (patch) | |
tree | feeee3d60e12ff29a9c408a2746c3d460968a81b | |
parent | 82deaa1e794fbdadf2c60f206966797bcd9f9ca1 (diff) | |
download | scala-3cc8af6179ac7b1778c19d96bfacd01120407d26.tar.gz scala-3cc8af6179ac7b1778c19d96bfacd01120407d26.tar.bz2 scala-3cc8af6179ac7b1778c19d96bfacd01120407d26.zip |
close #3207. review by odersky
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala | 10 | ||||
-rw-r--r-- | test/files/run/names-defaults.scala | 21 |
2 files changed, 28 insertions, 3 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala b/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala index b5c5bc95ae..89b4f910e5 100644 --- a/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala +++ b/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala @@ -210,8 +210,11 @@ trait NamesDefaults { self: Analyzer => blockWithoutQualifier(defaultQual) // super constructor calls - case Select(Super(_, _), _) if isConstr => - val defaultQual = moduleQual(baseFun.pos, mod => gen.mkAttributedRef(mod)) + case Select(sp @ Super(_, _), _) if isConstr => + // fix for #3207. selection of the companion module of the superclass + // needs to have the same prefix as the the superclass. + val superprefix = sp.symbol.tpe.parents.head.prefix + val defaultQual = moduleQual(baseFun.pos, mod => gen.mkAttributedRef(superprefix, mod)) blockWithoutQualifier(defaultQual) // self constructor calls (in secondary constructors) @@ -377,7 +380,8 @@ trait NamesDefaults { self: Analyzer => } else { val defGetterName = param.owner.name +"$default$"+ i if (param.owner.owner.isClass) { - param.owner.owner.info.member(defGetterName) + // .toInterface: otherwise we get the method symbol of the impl class + param.owner.owner.toInterface.info.member(defGetterName) } else { // the owner of the method is another method. find the default // getter in the context. diff --git a/test/files/run/names-defaults.scala b/test/files/run/names-defaults.scala index 8557047875..3442ecafc3 100644 --- a/test/files/run/names-defaults.scala +++ b/test/files/run/names-defaults.scala @@ -304,6 +304,27 @@ object Test extends Application { } + // #3207 + trait P3207[T] { + class Inner(val f: T => Unit = (x: T) => println(x)) + } + + object Test3207_1 { + val p = new P3207[Int] {} + val q = new p.Inner() { + def g = 0 + } + } + + object Test3207_2 { + val p = new P3207[Int] { + val inner = new Inner() { + def g = 0 + } + } + } + + // DEFINITIONS def test1(a: Int, b: String) = println(a +": "+ b) def test2(u: Int, v: Int)(k: String, l: Int) = println(l +": "+ k +", "+ (u + v)) |