summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala10
-rw-r--r--test/files/run/names-defaults.scala21
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))