From c882a2d67554509bddcad04ed6ff5fe43df1ceca Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Thu, 26 Nov 2009 12:03:24 +0000 Subject: Closed #2863 --- src/compiler/scala/tools/nsc/typechecker/Infer.scala | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/compiler/scala/tools/nsc/typechecker/Infer.scala b/src/compiler/scala/tools/nsc/typechecker/Infer.scala index f46043025a..ff09b40c73 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Infer.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Infer.scala @@ -35,6 +35,11 @@ trait Infer { def isVarArgs(formals: List[Type]) = !formals.isEmpty && isRepeatedParamType(formals.last) + def isWildcard(tp: Type) = tp match { + case WildcardType | BoundedWildcardType(_) => true + case _ => false + } + /** The formal parameter types corresponding to formals. * If formals has a repeated last parameter, a list of * (nargs - params.length + 1) copies of its type is returned. @@ -93,7 +98,7 @@ trait Infer { object instantiate extends TypeMap { private var excludedVars = scala.collection.immutable.Set[TypeVar]() def apply(tp: Type): Type = tp match { - case WildcardType | NoType => + case WildcardType | BoundedWildcardType(_) | NoType => throw new NoInstance("undetermined type") case tv @ TypeVar(origin, constr) => if (constr.inst == NoType) { @@ -118,7 +123,7 @@ trait Infer { * @return ... */ private[typechecker] def isFullyDefined(tp: Type): Boolean = tp match { - case WildcardType | NoType => + case WildcardType | BoundedWildcardType(_) | NoType => false case NoPrefix | ThisType(_) | ConstantType(_) => true @@ -237,7 +242,7 @@ trait Infer { def applyErrorMsg(tree: Tree, msg: String, argtpes: List[Type], pt: Type) = treeSymTypeMsg(tree) + msg + argtpes.mkString("(", ",", ")") + - (if (pt == WildcardType) "" else " with expected result type " + pt) + (if (isWildcard(pt)) "" else " with expected result type " + pt) // todo: use also for other error messages private def existentialContext(tp: Type) = tp.existentialSkolems match { @@ -584,7 +589,8 @@ trait Infer { (varianceInType(restpe)(tparam) & COVARIANT) == 0 // tparam occurred non-covariantly (in invariant or contravariant position) (tparams, targs).zipped map { (tparam, targ) => - if (targ.typeSymbol == NothingClass && (restpe == WildcardType || notCovariantIn(tparam, restpe))) { + if (targ.typeSymbol == NothingClass && + (isWildcard(restpe) || notCovariantIn(tparam, restpe))) { uninstantiated += tparam tparam.tpeHK //@M tparam.tpe was wrong: we only want the type constructor, // not the type constructor applied to dummy arguments -- cgit v1.2.3