summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2013-09-27 12:22:05 -0700
committerJason Zaugg <jzaugg@gmail.com>2013-09-27 12:22:05 -0700
commitd1e44d85a24aae9a83314fca5de07cf48e3e76ba (patch)
tree27b15caa37e2528a683e7feebf9463bee671c0ad /src
parentf9cd8ea3ca22264ab29d721633d312c850237121 (diff)
parent7fa77afa9322d4d31b132d1c1c8b57c7a3199348 (diff)
downloadscala-d1e44d85a24aae9a83314fca5de07cf48e3e76ba.tar.gz
scala-d1e44d85a24aae9a83314fca5de07cf48e3e76ba.tar.bz2
scala-d1e44d85a24aae9a83314fca5de07cf48e3e76ba.zip
Merge pull request #2996 from paulp/pr/3971
SI-3971 error message carat mispoints at curried methods.
Diffstat (limited to 'src')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala12
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala3
2 files changed, 14 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala b/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala
index 1f4d5cbac2..f893e4f0ff 100644
--- a/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala
@@ -157,6 +157,16 @@ trait ContextErrors {
}
def AdaptTypeError(tree: Tree, found: Type, req: Type) = {
+ // SI-3971 unwrapping to the outermost Apply helps prevent confusion with the
+ // error message point.
+ def callee = {
+ def unwrap(t: Tree): Tree = t match {
+ case Apply(app: Apply, _) => unwrap(app)
+ case _ => t
+ }
+ unwrap(tree)
+ }
+
// If the expected type is a refinement type, and the found type is a refinement or an anon
// class, we can greatly improve the error message by retyping the tree to recover the actual
// members present, then display along with the expected members. This is done here because
@@ -181,7 +191,7 @@ trait ContextErrors {
}
assert(!foundType.isErroneous && !req.isErroneous, (foundType, req))
- issueNormalTypeError(tree, withAddendum(tree.pos)(typeErrorMsg(foundType, req)))
+ issueNormalTypeError(callee, withAddendum(callee.pos)(typeErrorMsg(foundType, req)))
infer.explainTypes(foundType, req)
}
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index 157c6ba4de..d88a615c7f 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -4177,6 +4177,9 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
case If(_, t, e) => treesInResult(t) ++ treesInResult(e)
case Try(b, catches, _) => treesInResult(b) ++ catches
case Typed(r, Function(Nil, EmptyTree)) => treesInResult(r)
+ case Select(qual, name) => treesInResult(qual)
+ case Apply(fun, args) => treesInResult(fun) ++ args.flatMap(treesInResult)
+ case TypeApply(fun, args) => treesInResult(fun) ++ args.flatMap(treesInResult)
case _ => Nil
})
def errorInResult(tree: Tree) = treesInResult(tree) exists (_.pos == typeError.errPos)