From 9506d5273b4b10037c202f01e8556076998bd064 Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Tue, 4 Feb 2014 17:44:09 +0100 Subject: SI-8233 Fix regression in backend with boxed nulls Regressed in SI-7015 / 1b6661b8. We do need to "unbox" the null (ie, drop a stack from and load a null) in general. The only time we can avoid this is if the tree we are adapting is a `Constant(Literal(null))`. I've added a test for both backends. Only GenICode exhibited the problem. --- test/files/run/t8233-bcode.flags | 1 + test/files/run/t8233-bcode.scala | 18 ++++++++++++++++++ test/files/run/t8233.scala | 18 ++++++++++++++++++ 3 files changed, 37 insertions(+) create mode 100644 test/files/run/t8233-bcode.flags create mode 100644 test/files/run/t8233-bcode.scala create mode 100644 test/files/run/t8233.scala (limited to 'test/files') diff --git a/test/files/run/t8233-bcode.flags b/test/files/run/t8233-bcode.flags new file mode 100644 index 0000000000..c30091d3de --- /dev/null +++ b/test/files/run/t8233-bcode.flags @@ -0,0 +1 @@ +-Ybackend:GenBCode diff --git a/test/files/run/t8233-bcode.scala b/test/files/run/t8233-bcode.scala new file mode 100644 index 0000000000..fae1c2b702 --- /dev/null +++ b/test/files/run/t8233-bcode.scala @@ -0,0 +1,18 @@ +object Test { + def bar(s: String) = s; + val o: Option[Null] = None + def nullReference { + val a: Null = o.get + bar(a) // Was: VerifyError under GenICode + } + + def literal { + val a: Null = null + bar(a) + } + + def main(args: Array[String]) = { + try { nullReference } catch { case _: NoSuchElementException => } + literal + } +} diff --git a/test/files/run/t8233.scala b/test/files/run/t8233.scala new file mode 100644 index 0000000000..fae1c2b702 --- /dev/null +++ b/test/files/run/t8233.scala @@ -0,0 +1,18 @@ +object Test { + def bar(s: String) = s; + val o: Option[Null] = None + def nullReference { + val a: Null = o.get + bar(a) // Was: VerifyError under GenICode + } + + def literal { + val a: Null = null + bar(a) + } + + def main(args: Array[String]) = { + try { nullReference } catch { case _: NoSuchElementException => } + literal + } +} -- cgit v1.2.3