summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2015-02-05 12:23:21 +1000
committerJason Zaugg <jzaugg@gmail.com>2015-02-05 12:23:21 +1000
commit6b26f3b6a187c4c8f606b8f7e4b0ae84dc9cdebe (patch)
tree14f9bcade08538331530bbd66d1ca76df9d2e84f
parent67fd6557af837b19ff68f9292790bd293ce8009b (diff)
downloadscala-6b26f3b6a187c4c8f606b8f7e4b0ae84dc9cdebe.tar.gz
scala-6b26f3b6a187c4c8f606b8f7e4b0ae84dc9cdebe.tar.bz2
scala-6b26f3b6a187c4c8f606b8f7e4b0ae84dc9cdebe.zip
SI-9135 Fix NPE, a regression in the pattern matcher
The community build discovered that #4252 introduced the possibility for a NullPointerException. The tree with a null type was a synthetic `Apply(<<matchEnd>>)` created by the pattern matcher. This commit adds a null check.
-rw-r--r--src/reflect/scala/reflect/internal/Trees.scala2
-rw-r--r--test/files/pos/t9135.scala16
2 files changed, 17 insertions, 1 deletions
diff --git a/src/reflect/scala/reflect/internal/Trees.scala b/src/reflect/scala/reflect/internal/Trees.scala
index ccf907e05d..fd918b8595 100644
--- a/src/reflect/scala/reflect/internal/Trees.scala
+++ b/src/reflect/scala/reflect/internal/Trees.scala
@@ -1622,7 +1622,7 @@ trait Trees extends api.Trees {
}
private def invalidateSingleTypeCaches(tree: Tree): Unit = {
if (mutatedSymbols.nonEmpty)
- for (t <- tree)
+ for (t <- tree if t.tpe != null)
for (tp <- t.tpe) {
tp match {
case s: SingleType if mutatedSymbols contains s.sym =>
diff --git a/test/files/pos/t9135.scala b/test/files/pos/t9135.scala
new file mode 100644
index 0000000000..1e2c97baf9
--- /dev/null
+++ b/test/files/pos/t9135.scala
@@ -0,0 +1,16 @@
+
+class Free[A] {
+
+
+ this match {
+ case a @ Gosub() => gosub(a.a)(x => gosub(???)(???))
+ }
+ def gosub[A, B](a0: Free[A])(f0: A => Any): Free[B] = ???
+}
+
+
+
+ case class Gosub[B]() extends Free[B] {
+ type C
+ def a: Free[C] = ???
+ }