summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2007-03-16 13:36:40 +0000
committerMartin Odersky <odersky@gmail.com>2007-03-16 13:36:40 +0000
commit5de3ead55f9828c986f0369038d4e87432890f66 (patch)
treea7baa9b95714eb698c7d9fa7ffcb38879331dd81
parent3d4d7ce3ef2ef6a42c8e4f035058b4e5e76b88b1 (diff)
downloadscala-5de3ead55f9828c986f0369038d4e87432890f66.tar.gz
scala-5de3ead55f9828c986f0369038d4e87432890f66.tar.bz2
scala-5de3ead55f9828c986f0369038d4e87432890f66.zip
fixed bug1008
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Infer.scala13
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala4
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) =>