summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHubert Plociniczak <hubert.plociniczak@gmail.com>2012-05-21 14:35:49 +0200
committerHubert Plociniczak <hubert.plociniczak@gmail.com>2012-05-21 14:35:49 +0200
commitbbfbd6694d564552a6a8d903dc5d6e34f5976c2b (patch)
tree8b0cbcfe0d73b6017de68388947fa8bfc26dacd5 /src
parentef7708812fac32ca0c2a05330222a6b0806c9054 (diff)
downloadscala-bbfbd6694d564552a6a8d903dc5d6e34f5976c2b.tar.gz
scala-bbfbd6694d564552a6a8d903dc5d6e34f5976c2b.tar.bz2
scala-bbfbd6694d564552a6a8d903dc5d6e34f5976c2b.zip
Closes SI-5735, this could also potentially fix a SO problem that @adriaanm was experiencing in IDE but could not reproduce it.
Diffstat (limited to 'src')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala6
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Infer.scala6
2 files changed, 8 insertions, 4 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala b/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala
index df0258832c..7fa421e353 100644
--- a/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala
@@ -711,12 +711,14 @@ trait ContextErrors {
issueAmbiguousTypeError(pre, best, firstCompeting, AmbiguousTypeError(tree, pos, msg))
}
- def NoBestExprAlternativeError(tree: Tree, pt: Type) =
+ def NoBestExprAlternativeError(tree: Tree, pt: Type) = {
issueNormalTypeError(tree, withAddendum(tree.pos)(typeErrorMsg(tree.symbol.tpe, pt, isPossiblyMissingArgs(tree.symbol.tpe, pt))))
+ if (implicitly[Context].reportErrors) setError(tree)
+ }
def AmbiguousExprAlternativeError(tree: Tree, pre: Type, best: Symbol, firstCompeting: Symbol, pt: Type) = {
val (pos, msg) = ambiguousErrorMsgPos(tree.pos, pre, best, firstCompeting, "expected type " + pt)
- setError(tree)
+ if (implicitly[Context].ambiguousErrors) setError(tree)
issueAmbiguousTypeError(pre, best, firstCompeting, AmbiguousTypeError(tree, pos, msg))
}
diff --git a/src/compiler/scala/tools/nsc/typechecker/Infer.scala b/src/compiler/scala/tools/nsc/typechecker/Infer.scala
index 5534cd179c..ea0758e155 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Infer.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Infer.scala
@@ -1450,7 +1450,9 @@ trait Infer {
def inferExprAlternative(tree: Tree, pt: Type) = tree.tpe match {
case OverloadedType(pre, alts) => tryTwice {
val alts0 = alts filter (alt => isWeaklyCompatible(pre.memberType(alt), pt))
- val secondTry = alts0.isEmpty
+ // secondTry is not a sufficient condition to decide whether that was our final attempt.
+ // This is because it doesn't take into account tryTwice implicits search option.
+ val secondTry = alts0.isEmpty
val alts1 = if (secondTry) alts else alts0
//println("trying "+alts1+(alts1 map (_.tpe))+(alts1 map (_.locationString))+" for "+pt)
@@ -1481,7 +1483,7 @@ trait Infer {
// todo: missing test case
NoBestExprAlternativeError(tree, pt)
} else if (!competing.isEmpty) {
- if (secondTry) { NoBestExprAlternativeError(tree, pt); setError(tree) }
+ if (secondTry) NoBestExprAlternativeError(tree, pt)
else if (!pt.isErroneous) AmbiguousExprAlternativeError(tree, pre, best, competing.head, pt)
} else {
// val applicable = alts1 filter (alt =>