diff options
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Infer.scala | 13 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Typers.scala | 4 |
2 files changed, 15 insertions, 2 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Infer.scala b/src/compiler/scala/tools/nsc/typechecker/Infer.scala index c184a62784..0d5175a0f8 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Infer.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Infer.scala @@ -555,6 +555,19 @@ trait Infer requires Analyzer { false } + def isApplicableSafe(undetparams: List[Symbol], ftpe: Type, argtpes0: List[Type], pt: Type): boolean = { + val reportAmbiguousErrors = context.reportAmbiguousErrors + context.reportAmbiguousErrors = false + try { + isApplicable(undetparams, ftpe, argtpes0, pt) + } catch { + case ex: TypeError => + false + } finally { + context.reportAmbiguousErrors = reportAmbiguousErrors + } + } + /** Does type <code>ftpe1</code> specialize type <code>ftpe2</code> * when both are alternatives in an overloaded function? * diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 293d11053d..ab4cf811fa 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -1412,7 +1412,7 @@ trait Typers requires Analyzer { val argtypes = args map (arg => AllClass.tpe) val pre = fun.symbol.tpe.prefix var sym = fun.symbol filter { alt => - isApplicable(context.undetparams, pre.memberType(alt), argtypes, pt) + isApplicableSafe(context.undetparams, pre.memberType(alt), argtypes, pt) } if (sym hasFlag OVERLOADED) { // eliminate functions that would result from tupling transforms @@ -1529,7 +1529,7 @@ trait Typers requires Analyzer { error(fun.pos, "too many arguments for unapply pattern, maximum = "+MaxTupleArity) val arg = Ident(argDummy) setType argDummyType val oldArgType = arg.tpe - if (!isApplicable(List(), unappType, List(arg.tpe), WildcardType)) { + if (!isApplicableSafe(List(), unappType, List(arg.tpe), WildcardType)) { //Console.println("UNAPP: need to typetest, arg.tpe = "+arg.tpe+", unappType = "+unappType) def freshArgType(tp: Type): (Type, List[Symbol]) = tp match { case MethodType(formals, restpe) => |