From c490722ae1b7a9147bcdc884e362409b4017d19f Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Mon, 9 Nov 2009 10:02:50 +0000 Subject: Fixed #2504 Fixed #2517 --- src/compiler/scala/tools/nsc/typechecker/Implicits.scala | 2 +- src/compiler/scala/tools/nsc/typechecker/Infer.scala | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala index 1e07442eee..75a6796be6 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala @@ -384,7 +384,7 @@ self: Analyzer => } } - if (traceImplicits) println("typed impl for "+wildPt+"? "+info.name+":"+depoly(info.tpe)+"/"+undetParams+"/"+isPlausiblyCompatible(info.tpe, wildPt)+"/"+matchesPt(depoly(info.tpe), wildPt, List())) + //if (traceImplicits) println("typed impl for "+wildPt+"? "+info.name+":"+depoly(info.tpe)+"/"+undetParams+"/"+isPlausiblyCompatible(info.tpe, wildPt)+"/"+matchesPt(depoly(info.tpe), wildPt, List())) if (isPlausiblyCompatible(info.tpe, wildPt) && matchesPt(depoly(info.tpe), wildPt, List()) && isStable(info.pre)) { diff --git a/src/compiler/scala/tools/nsc/typechecker/Infer.scala b/src/compiler/scala/tools/nsc/typechecker/Infer.scala index c423258e00..3e83ecf272 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Infer.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Infer.scala @@ -841,6 +841,8 @@ trait Infer { false } + /** Todo: Try to make isApplicable always safe (i.e. not cause TypeErrors). + */ private[typechecker] def isApplicableSafe(undetparams: List[Symbol], ftpe: Type, argtpes0: List[Type], pt: Type): Boolean = { val reportAmbiguousErrors = context.reportAmbiguousErrors @@ -849,7 +851,12 @@ trait Infer { isApplicable(undetparams, ftpe, argtpes0, pt) } catch { case ex: TypeError => - false + try { + isApplicable(undetparams, ftpe, argtpes0, WildcardType) + } catch { + case ex: TypeError => + false + } } finally { context.reportAmbiguousErrors = reportAmbiguousErrors } @@ -1379,7 +1386,7 @@ trait Infer { check(pre, bound) case TypeRef(pre, sym, args) => if (sym.isAbstractType) - patternWarning(tp, "abstract type ") + if (!isLocalBinding(sym)) patternWarning(tp, "abstract type ") else if (sym.isAliasType) check(tp.normalize, bound) else if (sym == NothingClass || sym == NullClass || sym == AnyValClass) @@ -1624,7 +1631,7 @@ trait Infer { log("infer method alt "+ tree.symbol +" with alternatives "+ (alts map pre.memberType) +", argtpes = "+ argtpes +", pt = "+ pt) - val allApplicable = alts filter (alt => + var allApplicable = alts filter (alt => isApplicable(undetparams, followApply(pre.memberType(alt)), argtpes, pt)) // if there are multiple, drop those that use a default -- cgit v1.2.3