diff options
author | Dmitry Petrashko <dmitry.petrashko@gmail.com> | 2015-05-22 16:07:23 +0200 |
---|---|---|
committer | Dmitry Petrashko <dmitry.petrashko@gmail.com> | 2015-05-22 16:07:23 +0200 |
commit | 6965b470d433f501203c4e3d77b0919f826691ba (patch) | |
tree | 413446f1af3f40bb69499a60066609af6bc38d9f /tests/run/nothingTypeDce.scala | |
parent | 91bb668c5f1b6e5c51dad9b373c9398521508bc3 (diff) | |
download | dotty-6965b470d433f501203c4e3d77b0919f826691ba.tar.gz dotty-6965b470d433f501203c4e3d77b0919f826691ba.tar.bz2 dotty-6965b470d433f501203c4e3d77b0919f826691ba.zip |
Enable 440 run tests that pass.
Note that some of them may pass due to several bugs that interfere.
Diffstat (limited to 'tests/run/nothingTypeDce.scala')
-rw-r--r-- | tests/run/nothingTypeDce.scala | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/tests/run/nothingTypeDce.scala b/tests/run/nothingTypeDce.scala new file mode 100644 index 000000000..b1acb7d51 --- /dev/null +++ b/tests/run/nothingTypeDce.scala @@ -0,0 +1,63 @@ +// See comment in BCodeBodyBuilder + +// -target:jvm-1.6 -Ybackend:GenBCode -Yopt:unreachable-code +// target enables stack map frames generation + +class C { + // can't just emit a call to ???, that returns value of type Nothing$ (not Int). + def f1: Int = ??? + + def f2: Int = throw new Error("") + + def f3(x: Boolean) = { + var y = 0 + // cannot assign an object of type Nothing$ to Int + if (x) y = ??? + else y = 1 + y + } + + def f4(x: Boolean) = { + var y = 0 + // tests that whatever is emitted after the throw is valid (what? depends on opts, presence of stack map frames) + if (x) y = throw new Error("") + else y = 1 + y + } + + def f5(x: Boolean) = { + // stack heights need to be the same. ??? looks to the jvm like returning a value of + // type Nothing$, need to drop or throw it. + println( + if (x) { ???; 10 } + else 20 + ) + } + + def f6(x: Boolean) = { + println( + if (x) { throw new Error(""); 10 } + else 20 + ) + } + + def f7(x: Boolean) = { + println( + if (x) throw new Error("") + else 20 + ) + } + + def f8(x: Boolean) = { + println( + if (x) throw new Error("") + else 20 + ) + } +} + +object Test extends dotty.runtime.LegacyApp { + // creating an instance is enough to trigger bytecode verification for all methods, + // no need to invoke the methods. + new C() +} |