summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/typechecker/Typers.scala
diff options
context:
space:
mode:
authorHubert Plociniczak <hubert.plociniczak@gmail.com>2012-02-02 12:06:34 +0100
committerHubert Plociniczak <hubert.plociniczak@gmail.com>2012-02-02 13:45:30 +0100
commit4a083558bd20a46b0b29ed0b5b5ec7a0a1f29888 (patch)
tree3b20873f8fecb0f88dd95aa82560f1b97d56ae3f /src/compiler/scala/tools/nsc/typechecker/Typers.scala
parent3aebe255b87f534239f0c46a2a6e0d696c8a31d4 (diff)
downloadscala-4a083558bd20a46b0b29ed0b5b5ec7a0a1f29888.tar.gz
scala-4a083558bd20a46b0b29ed0b5b5ec7a0a1f29888.tar.bz2
scala-4a083558bd20a46b0b29ed0b5b5ec7a0a1f29888.zip
Fix sbt build with trunk.
This was tricky to find as HLists and multiple chains of implicits are definitely not fun to debug. Reporting ambiguous errors is influenced by the general error reporting, don't look for implicit arguments if any of the preceding ones failed (kills performance, causes diverging implicits with HLists). Previously throwing type errors handled that correctly but now we don't do that. Fixed small but essential typo when typing implicit. Review by @dragos
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker/Typers.scala')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index d3ff331f98..a90067a56c 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -100,6 +100,7 @@ trait Typers extends Modes with Adaptations with PatMatVirtualiser {
case MethodType(params, _) =>
val argResultsBuff = new ListBuffer[SearchResult]()
val argBuff = new ListBuffer[Tree]()
+ var paramFailed = false
def mkPositionalArg(argTree: Tree, paramName: Name) = argTree
def mkNamedArg(argTree: Tree, paramName: Name) = atPos(argTree.pos)(new AssignOrNamedArg(Ident(paramName), (argTree)))
@@ -114,14 +115,14 @@ trait Typers extends Modes with Adaptations with PatMatVirtualiser {
for(ar <- argResultsBuff)
paramTp = paramTp.subst(ar.subst.from, ar.subst.to)
- val res = inferImplicit(fun, paramTp, true, false, context)
+ val res = if (paramFailed) SearchFailure else inferImplicit(fun, paramTp, context.reportErrors, false, context)
argResultsBuff += res
if (res != SearchFailure) {
argBuff += mkArg(res.tree, param.name)
} else {
mkArg = mkNamedArg // don't pass the default argument (if any) here, but start emitting named arguments for the following args
- if (!param.hasDefault) {
+ if (!param.hasDefault && !paramFailed) {
context.errBuffer.find(_.kind == ErrorKinds.Divergent) match {
case Some(divergentImplicit) =>
// DivergentImplicit error has higher priority than "no implicit found"
@@ -133,6 +134,7 @@ trait Typers extends Modes with Adaptations with PatMatVirtualiser {
case None =>
NoImplicitFoundError(fun, param)
}
+ paramFailed = true
}
/* else {
TODO: alternative (to expose implicit search failure more) -->
@@ -767,7 +769,11 @@ trait Typers extends Modes with Adaptations with PatMatVirtualiser {
withCondConstrTyper(treeInfo.isSelfOrSuperConstrCall(tree)){ typer1 =>
if (original != EmptyTree && pt != WildcardType)
- typer1.silent(tpr => tpr.typed(tpr.applyImplicitArgs(tree), mode, pt)) match {
+ typer1.silent(tpr => {
+ val withImplicitArgs = tpr.applyImplicitArgs(tree)
+ if (tpr.context.hasErrors) tree // silent will wrap it in SilentTypeError anyway
+ else tpr.typed(withImplicitArgs, mode, pt)
+ }) match {
case SilentResultValue(result) =>
result
case _ =>