diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2014-05-18 12:01:17 +0200 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2014-05-18 12:04:27 +0200 |
commit | 0b432f9cd22b6e9770852e5b331a15f0534a312c (patch) | |
tree | 481b2a30ead8f171268d69f68b2506453eae9df8 /test/files/run | |
parent | ee611cd76c29fedd416162e482c7ab3f15b831ca (diff) | |
download | scala-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')
-rw-r--r-- | test/files/run/t8601c.flags | 1 | ||||
-rw-r--r-- | test/files/run/t8601c.scala | 12 |
2 files changed, 13 insertions, 0 deletions
diff --git a/test/files/run/t8601c.flags b/test/files/run/t8601c.flags new file mode 100644 index 0000000000..1182725e86 --- /dev/null +++ b/test/files/run/t8601c.flags @@ -0,0 +1 @@ +-optimize
\ No newline at end of file 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)) + + } +} |