diff options
author | Martin Odersky <odersky@gmail.com> | 2007-05-17 13:54:27 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2007-05-17 13:54:27 +0000 |
commit | 28cd5c6e5efd61951d3c0245e6c93ac69ad22f70 (patch) | |
tree | 788e8e6417e4f39b937fa11ac80371898a2ce3db | |
parent | 0e8ad86aa1f3bb3f05cc1efba205cab0fc5d1ba5 (diff) | |
download | scala-28cd5c6e5efd61951d3c0245e6c93ac69ad22f70.tar.gz scala-28cd5c6e5efd61951d3c0245e6c93ac69ad22f70.tar.bz2 scala-28cd5c6e5efd61951d3c0245e6c93ac69ad22f70.zip |
fixed bugs 1088, 1091
5 files changed, 16 insertions, 4 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/Trees.scala b/src/compiler/scala/tools/nsc/ast/Trees.scala index c28b0de4e9..57a4f10bd2 100644 --- a/src/compiler/scala/tools/nsc/ast/Trees.scala +++ b/src/compiler/scala/tools/nsc/ast/Trees.scala @@ -78,7 +78,12 @@ trait Trees { var tpe: Type = _ def setPos(pos: Position): this.type = { rawpos = pos; this } - def setType(tp: Type): this.type = { /*assert(kindingIrrelevant(tp) || !kindStar || !tp.isHigherKinded, ""+tp+" should not be higher-kinded");*/ tpe = tp; this } + def setType(tp: Type): this.type = { + /*assert(kindingIrrelevant(tp) || !kindStar || !tp.isHigherKinded, + tp+" should not be higher-kinded");*/ + tpe = tp + this + } def symbol: Symbol = null def symbol_=(sym: Symbol): unit = diff --git a/src/compiler/scala/tools/nsc/symtab/Symbols.scala b/src/compiler/scala/tools/nsc/symtab/Symbols.scala index 6643c8c4fa..c23477e3d0 100644 --- a/src/compiler/scala/tools/nsc/symtab/Symbols.scala +++ b/src/compiler/scala/tools/nsc/symtab/Symbols.scala @@ -239,6 +239,10 @@ trait Symbols { final def isPrivateLocal = hasFlag(PRIVATE) && hasFlag(LOCAL) + /** Is this symbol a protected local */ + final def isProtectedLocal = + hasFlag(PROTECTED) && hasFlag(LOCAL) + /** Does this symbol denote the primary constructor of its enclosing class? */ final def isPrimaryConstructor = isConstructor && owner.primaryConstructor == this diff --git a/src/compiler/scala/tools/nsc/typechecker/Infer.scala b/src/compiler/scala/tools/nsc/typechecker/Infer.scala index 1f2305446b..12935ab227 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Infer.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Infer.scala @@ -1158,6 +1158,7 @@ trait Infer { val applicable = alts1 filter (alt => global.typer.infer.isCompatible(pre.memberType(alt), pt)) checkNotShadowed(tree.pos, pre, best, applicable) + Console.println("infer expr alt, pre = "+pre+", alts = "+alts1+alts1.map(.tpe)+", best = "+best+":"+best.tpe) tree.setSymbol(best).setType(pre.memberType(best)) } } diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala index ae4fc804e6..8aa83f3438 100644 --- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala +++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala @@ -380,8 +380,10 @@ abstract class RefChecks extends InfoTransform { if ((sym hasFlag PARAM) && !sym.owner.isConstructor && !(tvar.isTypeParameterOrSkolem && sym.isTypeParameterOrSkolem && tvar.owner == sym.owner)) state = -state; - else if (!sym.owner.isClass || sym.isPrivateLocal) state = AnyVariance; - else if (sym.isAliasType) state = NoVariance; + else if (!sym.owner.isClass || sym.isPrivateLocal || sym.isProtectedLocal) + state = AnyVariance + else if (sym.isAliasType) + state = NoVariance sym = sym.owner } state diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index b71e17498a..b1e81f6ad4 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -1366,7 +1366,7 @@ trait Typers requires Analyzer { val member = stat.symbol if (context.owner.info.baseClasses.tail forall (bc => member.matchingSymbol(bc, context.owner.thisType) == NoSymbol)) { - if (!settings.Xexperimental.value) + if (!settings.Xexperimental.value && !member.isErroneous) error(member.pos, member.toString+" does not refine a member of its base type") } else { member setFlag OVERRIDE |