From d4748121aa58aa048a751a02d8f9910deab7f915 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Sun, 9 Jan 2011 04:11:43 +0000 Subject: Warded off an NPE (which only arose on erroneou... Warded off an NPE (which only arose on erroneous code) in the continuations plugin. Closes #4132, no review. --- src/compiler/scala/tools/nsc/ast/Trees.scala | 1 + .../plugin/scala/tools/selectivecps/CPSAnnotationChecker.scala | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/compiler/scala/tools/nsc/ast/Trees.scala b/src/compiler/scala/tools/nsc/ast/Trees.scala index 25c053c36d..30af9b0e8e 100644 --- a/src/compiler/scala/tools/nsc/ast/Trees.scala +++ b/src/compiler/scala/tools/nsc/ast/Trees.scala @@ -59,6 +59,7 @@ trait Trees extends reflect.generic.Trees { self: SymbolTable => } def isErroneous = (tree.tpe ne null) && tree.tpe.isErroneous + def isTyped = (tree.tpe ne null) && !tree.tpe.isErroneous /** Apply `f' to each subtree */ def foreach(f: Tree => Unit) { new ForeachTreeTraverser(f).traverse(tree) } diff --git a/src/continuations/plugin/scala/tools/selectivecps/CPSAnnotationChecker.scala b/src/continuations/plugin/scala/tools/selectivecps/CPSAnnotationChecker.scala index 9f38b9c15a..5151f1eeee 100644 --- a/src/continuations/plugin/scala/tools/selectivecps/CPSAnnotationChecker.scala +++ b/src/continuations/plugin/scala/tools/selectivecps/CPSAnnotationChecker.scala @@ -362,7 +362,7 @@ abstract class CPSAnnotationChecker extends CPSUtils { tree match { - case Apply(fun @ Select(qual, name), args) if (fun.tpe ne null) && !fun.tpe.isErroneous => + case Apply(fun @ Select(qual, name), args) if fun.isTyped => // HACK: With overloaded methods, fun will never get annotated. This is because // the 'overloaded' type gets annotated, but not the alternatives (among which @@ -372,12 +372,12 @@ abstract class CPSAnnotationChecker extends CPSUtils { transChildrenInOrder(tree, tpe, qual::(transArgList(fun, args).flatten), Nil) - case TypeApply(fun @ Select(qual, name), args) if (fun.tpe ne null) && !fun.tpe.isErroneous => + case TypeApply(fun @ Select(qual, name), args) if fun.isTyped => vprintln("[checker] checking select apply " + tree + "/" + tpe) transChildrenInOrder(tree, tpe, List(qual, fun), Nil) - case Apply(fun, args) if (fun.tpe ne null) && !fun.tpe.isErroneous => + case Apply(fun, args) if fun.isTyped => vprintln("[checker] checking unknown apply " + tree + "/" + tpe) @@ -389,7 +389,7 @@ abstract class CPSAnnotationChecker extends CPSUtils { transChildrenInOrder(tree, tpe, List(fun), Nil) - case Select(qual, name) => + case Select(qual, name) if qual.isTyped => vprintln("[checker] checking select " + tree + "/" + tpe) -- cgit v1.2.3