summaryrefslogtreecommitdiff
path: root/test/files/run/t8601c.scala
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2014-05-18 12:01:17 +0200
committerJason Zaugg <jzaugg@gmail.com>2014-05-18 12:04:27 +0200
commit0b432f9cd22b6e9770852e5b331a15f0534a312c (patch)
tree481b2a30ead8f171268d69f68b2506453eae9df8 /test/files/run/t8601c.scala
parentee611cd76c29fedd416162e482c7ab3f15b831ca (diff)
downloadscala-0b432f9cd22b6e9770852e5b331a15f0534a312c.tar.gz
scala-0b432f9cd22b6e9770852e5b331a15f0534a312c.tar.bz2
scala-0b432f9cd22b6e9770852e5b331a15f0534a312c.zip
SI-8601 Avoid over-eager optimization of LOAD_FIELD
It can NPE or trigger static class initilization, we can't elimiate it without changing semantics.
Diffstat (limited to 'test/files/run/t8601c.scala')
-rw-r--r--test/files/run/t8601c.scala12
1 files changed, 12 insertions, 0 deletions
diff --git a/test/files/run/t8601c.scala b/test/files/run/t8601c.scala
new file mode 100644
index 0000000000..c487d6825e
--- /dev/null
+++ b/test/files/run/t8601c.scala
@@ -0,0 +1,12 @@
+object Test {
+ def loadField(x: scala.runtime.IntRef): Unit = x.elem
+ def storeField(x: scala.runtime.IntRef): Unit = x.elem = 42
+
+ def check(x: => Any) = try { x; sys.error("failed to throw NPE!") } catch { case _: NullPointerException => }
+
+ def main(args: Array[String]) {
+ check(loadField(null)) // bug: did not NPE under -Ydead-code
+ check(storeField(null))
+
+ }
+}