summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2012-12-22 10:12:03 -0800
committerPaul Phillips <paulp@improving.org>2012-12-24 13:04:44 -0800
commit231d59dcf57af99a9e2a1366afd18680c13cd6ce (patch)
tree4a06a09da8d151fcb266832cf55073995d452cb8 /src
parent5666468d1bf907295d724d16f52c413696c6efe2 (diff)
downloadscala-231d59dcf57af99a9e2a1366afd18680c13cd6ce.tar.gz
scala-231d59dcf57af99a9e2a1366afd18680c13cd6ce.tar.bz2
scala-231d59dcf57af99a9e2a1366afd18680c13cd6ce.zip
SI-6829, SI-6788, NPEs during erroneous compilation.
Have to intercept trees which have a null type due to errors before they leave the warm confines of 'def typed' because from that point everything assumes tree.tpe != null.
Diffstat (limited to 'src')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index e45d64ade5..9d390476db 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -5264,7 +5264,7 @@ trait Typers extends Modes with Adaptations with Tags {
def typedDocDef(docdef: DocDef) = {
if (forScaladoc && (sym ne null) && (sym ne NoSymbol)) {
- val comment = docdef.comment
+ val comment = docdef.comment
docComments(sym) = comment
comment.defineVariables(sym)
val typer1 = newTyper(context.makeNewScope(tree, context.owner))
@@ -5595,12 +5595,18 @@ trait Typers extends Modes with Adaptations with Tags {
"context.owner" -> context.owner
)
)
- val tree1 = typed1(tree, mode, dropExistential(pt))
+ typed1(tree, mode, dropExistential(pt))
+ }
+ // Can happen during erroneous compilation - error(s) have been
+ // reported, but we need to avoid causing an NPE with this tree
+ if (tree1.tpe eq null)
+ return setError(tree)
+
+ if (!alreadyTyped) {
printTyping("typed %s: %s%s".format(
ptTree(tree1), tree1.tpe,
if (isSingleType(tree1.tpe)) " with underlying "+tree1.tpe.widen else "")
)
- tree1
}
tree1.tpe = addAnnotations(tree1, tree1.tpe)