summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2012-02-14 06:16:09 -0800
committerPaul Phillips <paulp@improving.org>2012-02-14 06:18:19 -0800
commita725bf982c06e16c5d533ea6b2227b726db4f7e4 (patch)
tree9348691a431d3b3a370e36db455a15da4e7a687f
parentbd988df6448bfeacf8fa6bf35b21881d3073a547 (diff)
downloadscala-a725bf982c06e16c5d533ea6b2227b726db4f7e4.tar.gz
scala-a725bf982c06e16c5d533ea6b2227b726db4f7e4.tar.bz2
scala-a725bf982c06e16c5d533ea6b2227b726db4f7e4.zip
Make fix for SI-5452 not break other things.
If this looks hacky, that's because it is.
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala4
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Infer.scala7
-rw-r--r--test/files/neg/t5452.check4
3 files changed, 10 insertions, 5 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala b/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala
index 466b5125a8..6ee09d064f 100644
--- a/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala
@@ -714,11 +714,9 @@ trait ContextErrors {
setError(tree)
}
- def NoBestMethodAlternativeError(tree: Tree, argtpes: List[Type], pt: Type) = {
+ def NoBestMethodAlternativeError(tree: Tree, argtpes: List[Type], pt: Type) =
issueNormalTypeError(tree,
applyErrorMsg(tree, " cannot be applied to ", argtpes, pt))
- setError(tree)
- }
def AmbiguousMethodAlternativeError(tree: Tree, pre: Type, best: Symbol,
firstCompeting: Symbol, argtpes: List[Type], pt: Type) = {
diff --git a/src/compiler/scala/tools/nsc/typechecker/Infer.scala b/src/compiler/scala/tools/nsc/typechecker/Infer.scala
index b97fbebec2..acf905d974 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Infer.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Infer.scala
@@ -1466,7 +1466,9 @@ trait Infer {
argtpes: List[Type], pt0: Type, varArgsOnly: Boolean = false): Unit = tree.tpe match {
case OverloadedType(pre, alts) =>
val pt = if (pt0.typeSymbol == UnitClass) WildcardType else pt0
+ var secondTry = true
tryTwice {
+ secondTry = !secondTry
debuglog("infer method alt "+ tree.symbol +" with alternatives "+
(alts map pre.memberType) +", argtpes = "+ argtpes +", pt = "+ pt)
@@ -1488,8 +1490,11 @@ trait Infer {
if (improves(alt, best)) alt else best)
val competing = applicable.dropWhile(alt => best == alt || improves(best, alt))
if (best == NoSymbol) {
- if (pt == WildcardType)
+ if (pt == WildcardType) {
NoBestMethodAlternativeError(tree, argtpes, pt)
+ if (secondTry)
+ setError(tree)
+ }
else
inferMethodAlternative(tree, undetparams, argtpes, WildcardType)
} else if (!competing.isEmpty) {
diff --git a/test/files/neg/t5452.check b/test/files/neg/t5452.check
index baf544499b..2f35a45509 100644
--- a/test/files/neg/t5452.check
+++ b/test/files/neg/t5452.check
@@ -1,5 +1,7 @@
t5452.scala:28: error: overloaded method value apply with alternatives:
-
+ ()Queryable[CoffeesTable] <and>
+ (t: Tree)(implicit evidence$2: Manifest[CoffeesTable])Nothing <and>
+ (implicit evidence$1: Manifest[CoffeesTable])Nothing
cannot be applied to (Queryable[CoffeesTable])
Queryable[CoffeesTable]( q.treeFilter(null) )
^