From 9b8f5acf89d1face47513bdb19d564f1f57e4c59 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Fri, 22 Apr 2011 09:21:28 +0000 Subject: Fixed spurious qualification of types that are ... Fixed spurious qualification of types that are locally quantified. Review by extempore. --- .../scala/tools/nsc/typechecker/TypeDiagnostics.scala | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala') diff --git a/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala b/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala index b0547cb2e2..2abecfa572 100644 --- a/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala +++ b/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala @@ -195,8 +195,9 @@ trait TypeDiagnostics { def resType = if (pt isWildcard) "" else " with expected result type " + pt def allTypes = (alternatives(tree) flatMap (_.paramTypes)) ++ argtpes :+ pt + def locals = alternatives(tree) flatMap (_.typeParams) - withDisambiguation(allTypes: _*) { + withDisambiguation(locals, allTypes: _*) { treeSymTypeMsg(tree) + msg + asParams(argtpes) + resType } } @@ -292,7 +293,7 @@ trait TypeDiagnostics { } def foundReqMsg(found: Type, req: Type): String = { - (withDisambiguation(found, req) { + (withDisambiguation(List(), found, req) { ";\n found : " + found.toLongString + existentialContext(found) + "\n required: " + req + existentialContext(req) }) + explainVariance(found, req) @@ -344,17 +345,16 @@ trait TypeDiagnostics { ) } } - private def typeDiags(types: Type*): List[TypeDiag] = { + private def typeDiags(locals: List[Symbol], types: Type*): List[TypeDiag] = { object SymExtractor { def unapply(x: Any) = x match { case t @ ConstantType(_) => Some(t -> t.underlying.typeSymbol) - case t @ TypeRef(_, sym, _) => Some(t -> sym) + case t @ TypeRef(_, sym, _) => if (locals contains sym) None else Some(t -> sym) case _ => None } } - for (tp <- types.toList ; SymExtractor(t, sym) <- tp) yield - TypeDiag(t, sym) + for (tp <- types.toList; SymExtractor(t, sym) <- tp) yield TypeDiag(t, sym) } /** The distinct pairs from an ordered list. */ @@ -367,8 +367,8 @@ trait TypeDiagnostics { * until they can be distinguished from one another: then executes the given * code. The names are restored and the result is returned. */ - def withDisambiguation[T](types: Type*)(op: => T): T = { - val typeRefs = typeDiags(types: _*) + def withDisambiguation[T](locals: List[Symbol], types: Type*)(op: => T): T = { + val typeRefs = typeDiags(locals, types: _*) val toCheck = pairs(typeRefs) filterNot { case (td1, td2) => td1 sym_== td2 } ultimately(typeRefs foreach (_.restoreName())) { -- cgit v1.2.3