diff options
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Typers.scala | 41 | ||||
-rw-r--r-- | test/files/neg/bug1017.check | 4 | ||||
-rw-r--r-- | test/files/neg/bug1017.scala | 4 |
3 files changed, 35 insertions, 14 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index aff947c210..630a5253ef 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -1695,21 +1695,34 @@ trait Typers requires Analyzer { case t: Tree => t case ex: TypeError => - val Select(qual, name) = fun - val args1 = tryTypedArgs(args, ex) - val qual1 = - if ((args1 ne null) && !pt.isError) { - def templateArgType(arg: Tree) = - new BoundedWildcardType(mkTypeBounds(arg.tpe, AnyClass.tpe)) - adaptToMember(qual, name, MethodType(args1 map templateArgType, pt)) - } else qual - if (qual1 ne qual) { - val tree1 = Apply(Select(qual1, name) setPos fun.pos, args1) setPos tree.pos - typed1(tree1, mode | SNDTRYmode, pt) - } else { - reportTypeError(tree.pos, ex) - setError(tree) + def errorInResult(tree: Tree): boolean = tree.pos == ex.pos || { + tree match { + case Block(_, r) => errorInResult(r) + case Match(_, cases) => cases exists errorInResult + case CaseDef(_, _, r) => errorInResult(r) + case Annotated(_, r) => errorInResult(r) + case If(_, t, e) => errorInResult(t) || errorInResult(e) + case Try(b, catches, _) => errorInResult(b) || (catches exists errorInResult) + case Typed(r, Function(List(), EmptyTree)) => errorInResult(r) + case _ => false + } } + if (errorInResult(fun) || (args exists errorInResult)) { + val Select(qual, name) = fun + val args1 = tryTypedArgs(args, ex) + val qual1 = + if ((args1 ne null) && !pt.isError) { + def templateArgType(arg: Tree) = + new BoundedWildcardType(mkTypeBounds(arg.tpe, AnyClass.tpe)) + adaptToMember(qual, name, MethodType(args1 map templateArgType, pt)) + } else qual + if (qual1 ne qual) { + val tree1 = Apply(Select(qual1, name) setPos fun.pos, args1) setPos tree.pos + return typed1(tree1, mode | SNDTRYmode, pt) + } + } + reportTypeError(tree.pos, ex) + setError(tree) } def convertToAssignment(fun: Tree, qual: Tree, name: Name, args: List[Tree], ex: TypeError): Tree = { diff --git a/test/files/neg/bug1017.check b/test/files/neg/bug1017.check new file mode 100644 index 0000000000..ad88a10401 --- /dev/null +++ b/test/files/neg/bug1017.check @@ -0,0 +1,4 @@ +bug1017.scala:3: error: not found: value foo +<x><x><x><x><x><x><x><x><x><x><x><x><x><x><x><x><x><x>{ foo }</x></x></x></x></x></x></x></x></x></x></x></x></x></x></x></x></x></x> + ^ +one error found diff --git a/test/files/neg/bug1017.scala b/test/files/neg/bug1017.scala new file mode 100644 index 0000000000..e389f308c3 --- /dev/null +++ b/test/files/neg/bug1017.scala @@ -0,0 +1,4 @@ +// 'foo' is not defined +object Test { +<x><x><x><x><x><x><x><x><x><x><x><x><x><x><x><x><x><x>{ foo }</x></x></x></x></x></x></x></x></x></x></x></x></x></x></x></x></x></x> +} |