Skip to content

Commit

Permalink
Fixes SI-5801, error messages regression. Review by @adriaanm
Browse files Browse the repository at this point in the history
  • Loading branch information
hubertp committed May 18, 2012
1 parent 97046e6 commit 7490250
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/compiler/scala/tools/nsc/typechecker/Typers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,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
Expand All @@ -124,7 +126,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) {
Expand Down
22 changes: 22 additions & 0 deletions test/files/neg/t5801.check
Original file line number Diff line number Diff line change
@@ -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
16 changes: 16 additions & 0 deletions test/files/neg/t5801.scala
Original file line number Diff line number Diff line change
@@ -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)
}

3 comments on commit 7490250

@adriaanm
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hubertp
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was based on an old master. Everything is fine.

@adriaanm
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, sorry for the confusion

Please sign in to comment.