diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2013-09-27 12:22:05 -0700 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2013-09-27 12:22:05 -0700 |
commit | d1e44d85a24aae9a83314fca5de07cf48e3e76ba (patch) | |
tree | 27b15caa37e2528a683e7feebf9463bee671c0ad /src/compiler | |
parent | f9cd8ea3ca22264ab29d721633d312c850237121 (diff) | |
parent | 7fa77afa9322d4d31b132d1c1c8b57c7a3199348 (diff) | |
download | scala-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/compiler')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala | 12 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Typers.scala | 3 |
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) |