summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdriaan Moors <adriaan.moors@epfl.ch>2012-05-19 02:21:48 -0700
committerAdriaan Moors <adriaan.moors@epfl.ch>2012-05-19 02:21:48 -0700
commit8cb13b1017ef6ed8281964c51df48d4bb9dcaa99 (patch)
tree5a83a30e747c6a90f383dee6f3ce902c09407f65
parent5b9bf3d7124e8ba6e27953fa5cc00367614ecf5b (diff)
parent7490250efe8e7b59be9d168048f40344b3066b61 (diff)
downloadscala-8cb13b1017ef6ed8281964c51df48d4bb9dcaa99.tar.gz
scala-8cb13b1017ef6ed8281964c51df48d4bb9dcaa99.tar.bz2
scala-8cb13b1017ef6ed8281964c51df48d4bb9dcaa99.zip
Merge pull request #568 from hubertp/issue/5801
Fix SI-5801: error messages regression.
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala4
-rw-r--r--test/files/neg/t5801.check22
-rw-r--r--test/files/neg/t5801.scala16
3 files changed, 41 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index 7419ec3bce..e40a567f1d 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -114,6 +114,8 @@ trait Typers extends Modes with Adaptations with Taggings {
case MethodType(params, _) =>
val argResultsBuff = new ListBuffer[SearchResult]()
val argBuff = new ListBuffer[Tree]()
+ // paramFailed cannot be initialized with params.exists(_.tpe.isError) because that would
+ // hide some valid errors for params preceding the erroneous one.
var paramFailed = false
def mkPositionalArg(argTree: Tree, paramName: Name) = argTree
@@ -129,7 +131,7 @@ trait Typers extends Modes with Adaptations with Taggings {
for(ar <- argResultsBuff)
paramTp = paramTp.subst(ar.subst.from, ar.subst.to)
- val res = if (paramFailed) SearchFailure else inferImplicit(fun, paramTp, context.reportErrors, false, context)
+ val res = if (paramFailed || (paramTp.isError && {paramFailed = true; true})) SearchFailure else inferImplicit(fun, paramTp, context.reportErrors, false, context)
argResultsBuff += res
if (res != SearchFailure) {
diff --git a/test/files/neg/t5801.check b/test/files/neg/t5801.check
new file mode 100644
index 0000000000..abf8e6e932
--- /dev/null
+++ b/test/files/neg/t5801.check
@@ -0,0 +1,22 @@
+t5801.scala:1: error: object sth is not a member of package scala
+import scala.sth
+ ^
+t5801.scala:4: error: not found: value sth
+ def foo(a: Int)(implicit b: sth.Sth): Unit = {}
+ ^
+t5801.scala:7: error: not found: value sth
+ def bar(x: Int)(implicit y: Int): sth.Sth = null
+ ^
+t5801.scala:8: error: could not find implicit value for parameter y: Int
+ bar(1)
+ ^
+t5801.scala:10: error: not found: value sth
+ def meh(x: Int)(implicit a: sth.Sth, b: Int): Unit = {}
+ ^
+t5801.scala:13: error: not found: value sth
+ def meh2(x: Int)(implicit b: Int, a: sth.Sth): Unit = {}
+ ^
+t5801.scala:14: error: could not find implicit value for parameter b: Int
+ meh2(1)
+ ^
+7 errors found
diff --git a/test/files/neg/t5801.scala b/test/files/neg/t5801.scala
new file mode 100644
index 0000000000..d452222ac8
--- /dev/null
+++ b/test/files/neg/t5801.scala
@@ -0,0 +1,16 @@
+import scala.sth
+
+object Test extends App {
+ def foo(a: Int)(implicit b: sth.Sth): Unit = {}
+ foo(1)
+
+ def bar(x: Int)(implicit y: Int): sth.Sth = null
+ bar(1)
+
+ def meh(x: Int)(implicit a: sth.Sth, b: Int): Unit = {}
+ meh(1)
+
+ def meh2(x: Int)(implicit b: Int, a: sth.Sth): Unit = {}
+ meh2(1)
+}
+