diff options
author | Lukas Rytz <lukas.rytz@gmail.com> | 2016-12-12 16:25:23 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-12-12 16:25:23 +0100 |
commit | 8b872daacbb41dc9947ad181ba79e660c55a6683 (patch) | |
tree | af3c865b0d9327fe131cdbde7dc433c4a52d66c3 /test/files | |
parent | 2d90142eca20416971d3f8a2d79aaf0a4531b8ce (diff) | |
parent | 880aec04e82ad3a9a2feb3b83b779f192d84e01e (diff) | |
download | scala-8b872daacbb41dc9947ad181ba79e660c55a6683.tar.gz scala-8b872daacbb41dc9947ad181ba79e660c55a6683.tar.bz2 scala-8b872daacbb41dc9947ad181ba79e660c55a6683.zip |
Merge pull request #5543 from retronym/ticket/10069
SI-10069 Fix code gen errors with array updates, Nothing
Diffstat (limited to 'test/files')
-rw-r--r-- | test/files/run/t10069.scala | 34 | ||||
-rw-r--r-- | test/files/run/t10069b.scala | 13 |
2 files changed, 47 insertions, 0 deletions
diff --git a/test/files/run/t10069.scala b/test/files/run/t10069.scala new file mode 100644 index 0000000000..4e70b7e814 --- /dev/null +++ b/test/files/run/t10069.scala @@ -0,0 +1,34 @@ +object Expected extends Exception +object Test { + def throwExpected: Nothing = throw Expected + def foo0(a: Array[Double]) = { // does compile for Int instead of Double + val v = 42 + a(0) = throwExpected // was crash in code gen: java.lang.NegativeArraySizeException + } + + def foo1(a: Array[Double]) = { // does compile for Int instead of Double + a(0) = throwExpected // was VerifyError at runtime + } + + def foo2(a: Array[Int]) = { // does compile for Int instead of Double + a(0) = throwExpected // was VerifyError at runtime + } + + def foo3(a: Array[String]) = { // does compile for Int instead of Double + a(0) = throwExpected // was already working + } + + + def main(args: Array[String]): Unit = { + check(foo0(new Array[Double](1))) + check(foo1(new Array[Double](1))) + check(foo2(new Array[Int](1))) + check(foo3(new Array[String](1))) + } + def check(f: => Any) { + try {f ; sys.error("no exception thrown") + } catch { + case Expected => + } + } +} diff --git a/test/files/run/t10069b.scala b/test/files/run/t10069b.scala new file mode 100644 index 0000000000..c9d652bb0c --- /dev/null +++ b/test/files/run/t10069b.scala @@ -0,0 +1,13 @@ +object Test { + def main(args: Array[String]): Unit = { + try { + Int.box(???) // crashed the compiler: java.util.NoSuchElementException: key not found: Lscala/runtime/Nothing$; + sys.error("no exception") + } catch { + case _: NotImplementedError => + // oka + case e: Throwable => + sys.error("wrong exception: " + e) + } + } +} |