close #3207. review by odersky

git-svn-id: http://lampsvn.epfl.ch/svn-repos/scala/scala/trunk@21396 5e8d7ff9-d8ef-0310-90f0-a4852d11357a
This commit is contained in:
rytz 2010-04-09 09:51:00 +00:00
parent 954e3feaf8
commit a063183d5a
2 changed files with 28 additions and 3 deletions

View File

@ -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.

View File

@ -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))