diff options
author | Martin Odersky <odersky@gmail.com> | 2006-11-11 20:33:30 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2006-11-11 20:33:30 +0000 |
commit | 9a326616b44a861ee1c1d792996a9b6079a63645 (patch) | |
tree | d9883cd58bee3b04c1d0b44d4d68fba693c895b5 /src | |
parent | de92a193eb5b1e225edd968106aec5af8d6b5e93 (diff) | |
download | scala-9a326616b44a861ee1c1d792996a9b6079a63645.tar.gz scala-9a326616b44a861ee1c1d792996a9b6079a63645.tar.bz2 scala-9a326616b44a861ee1c1d792996a9b6079a63645.zip |
fied bugs 815,816,817
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/symtab/Types.scala | 23 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Infer.scala | 23 |
2 files changed, 29 insertions, 17 deletions
diff --git a/src/compiler/scala/tools/nsc/symtab/Types.scala b/src/compiler/scala/tools/nsc/symtab/Types.scala index e12c6dfe7e..091d7117ef 100644 --- a/src/compiler/scala/tools/nsc/symtab/Types.scala +++ b/src/compiler/scala/tools/nsc/symtab/Types.scala @@ -1648,11 +1648,14 @@ trait Types requires SymbolTable { object adaptToNewRunMap extends TypeMap { private def adaptToNewRun(pre: Type, sym: Symbol): Symbol = { - if (sym.isModuleClass && !phase.flatClasses) + if (sym.isModuleClass && !phase.flatClasses) { adaptToNewRun(pre, sym.sourceModule).moduleClass - else if ((pre eq NoPrefix) || (pre eq NoType)) sym - else if (sym.owner.isPackageClass) sym.owner.info.decl(sym.name) - else { + } else if ((pre eq NoPrefix) || (pre eq NoType)) { + sym + } else if (sym.owner.isPackageClass) { + val sym1 = sym.owner.info.decl(sym.name) + if (sym1 != NoSymbol && sym1.validTo > sym.validTo) sym1 else sym + } else { var rebind0 = pre.findMember(sym.name, BRIDGE, 0, true) /** The two symbols have the same fully qualified name */ def corresponds(sym1: Symbol, sym2: Symbol): boolean = @@ -2038,7 +2041,7 @@ trait Types requires SymbolTable { */ private def limitRecursion(tps: List[Type], boundkind: String, op: List[Type] => Type): Type = - if (recCount == recLimit) { + if (recCount >= recLimit) { giveUp = true AnyClass.tpe } else { @@ -2191,7 +2194,8 @@ trait Types requires SymbolTable { val lubType = refinedType(lubParents, lubOwner) val lubThisType = lubType.symbol.thisType val narrowts = ts map (.narrow) - def lubsym(proto: Symbol): Symbol = { + def lubsym(proto: Symbol): Symbol = try { + recCount = recCount + 1 // short circuit nesting levels for refinements val prototp = lubThisType.memberInfo(proto) val syms = narrowts map (t => t.nonPrivateMember(proto.name).suchThat(sym => @@ -2212,6 +2216,8 @@ trait Types requires SymbolTable { .setInfo(lubBounds(symtypes map (.bounds))) } } + } finally { + recCount = recCount - 1 } def refines(tp: Type, sym: Symbol): boolean = { val syms = tp.nonPrivateMember(sym.name).alternatives; @@ -2268,7 +2274,8 @@ trait Types requires SymbolTable { if (computeRefinement) { val glbType = refinedType(ts, glbOwner) val glbThisType = glbType.symbol.thisType - def glbsym(proto: Symbol): Symbol = { + def glbsym(proto: Symbol): Symbol = try { + recCount = recCount + 1 // short circuit nesting levels for refinements val prototp = glbThisType.memberInfo(proto) val syms = for ( val t <- ts; @@ -2299,6 +2306,8 @@ trait Types requires SymbolTable { else throw new MalformedClosure(symtypes); result }) + } finally { + recCount = recCount - 1 } for (val t <- ts; val sym <- t.nonPrivateMembers) if (!sym.isClass && !sym.isConstructor && !(glbThisType specializes sym)) diff --git a/src/compiler/scala/tools/nsc/typechecker/Infer.scala b/src/compiler/scala/tools/nsc/typechecker/Infer.scala index 2482bff9cd..a758f8abe6 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Infer.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Infer.scala @@ -923,14 +923,15 @@ trait Infer requires Analyzer { /* -- Overload Resolution ---------------------------------------------- */ def checkNotShadowed(pos: PositionType, pre: Type, best: Symbol, eligible: List[Symbol]) = - for (val alt <- eligible) { - if (alt.owner != best.owner && alt.owner.isSubClass(best.owner)) - error(pos, - "erroneous reference to overloaded definition,\n"+ - "most specific definition is: "+best+best.locationString+" of type "+pre.memberType(best)+ - ",\nyet alternative definition "+alt+alt.locationString+" of type "+pre.memberType(alt)+ - "\nis defined in a subclass") - } + if (!phase.erasedTypes) + for (val alt <- eligible) { + if (alt.owner != best.owner && alt.owner.isSubClass(best.owner)) + error(pos, + "erroneous reference to overloaded definition,\n"+ + "most specific definition is: "+best+best.locationString+" of type "+pre.memberType(best)+ + ",\nyet alternative definition "+alt+alt.locationString+" of type "+pre.memberType(alt)+ + "\nis defined in a subclass") + } /** Assign <code>tree</code> the symbol and type of the alternative which * matches prototype <code>pt</code>, if it exists. @@ -970,7 +971,9 @@ trait Infer requires Analyzer { () } else { - //checkNotShadowed(tree.pos, pre, best, alts1) + val applicable = alts1 filter (alt => + global.typer.infer.isCompatible(pre.memberType(alt), pt)) + checkNotShadowed(tree.pos, pre, best, applicable) tree.setSymbol(best).setType(pre.memberType(best)) } } @@ -1009,7 +1012,7 @@ trait Infer requires Analyzer { setError(tree) () } else { - //checkNotShadowed(tree.pos, pre, best, applicable) + checkNotShadowed(tree.pos, pre, best, applicable) tree.setSymbol(best).setType(pre.memberType(best)) } } |