summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2013-09-27 09:25:37 -0700
committerPaul Phillips <paulp@improving.org>2013-09-27 09:42:37 -0700
commit7fa77afa9322d4d31b132d1c1c8b57c7a3199348 (patch)
tree17bef811bee14d52333af56120a802d02a013948 /src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala
parent1a3c16fd36407bb2308bbb84739601544ac4a2e5 (diff)
downloadscala-7fa77afa9322d4d31b132d1c1c8b57c7a3199348.tar.gz
scala-7fa77afa9322d4d31b132d1c1c8b57c7a3199348.tar.bz2
scala-7fa77afa9322d4d31b132d1c1c8b57c7a3199348.zip
SI-3971 error message carat mispoints at curried methods.
Point at the beginning of the first argument list when reporting an error, as this is most easily associated with the application taking place (which may involve multiple applies in succession.) Thanks to retronym for figuring out why issuing a better error message broke the compiler on non-erroneous compile runs. The changes to "treesInResult" are the consequence.
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala12
1 files changed, 11 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)
}