diff options
author | Som Snytt <som.snytt@gmail.com> | 2012-02-21 12:01:27 -0800 |
---|---|---|
committer | Som Snytt <som.snytt@gmail.com> | 2012-02-21 12:01:27 -0800 |
commit | f26a47c4e8bda2f6c689b4e9b0bb5c64ccf4c699 (patch) | |
tree | 1b2bfc54bb5afed46813021fc00cb5b911215fbb /test | |
parent | fbb7865e137e83660257fdc79d19d29ff39c775b (diff) | |
download | scala-f26a47c4e8bda2f6c689b4e9b0bb5c64ccf4c699.tar.gz scala-f26a47c4e8bda2f6c689b4e9b0bb5c64ccf4c699.tar.bz2 scala-f26a47c4e8bda2f6c689b4e9b0bb5c64ccf4c699.zip |
Disallow eliding when Nothing is expected
Diffstat (limited to 'test')
-rw-r--r-- | test/files/neg/elide-to-nothing.check | 4 | ||||
-rw-r--r-- | test/files/neg/elide-to-nothing.flags | 1 | ||||
-rw-r--r-- | test/files/neg/elide-to-nothing.scala | 31 |
3 files changed, 36 insertions, 0 deletions
diff --git a/test/files/neg/elide-to-nothing.check b/test/files/neg/elide-to-nothing.check new file mode 100644 index 0000000000..3ef05aac9a --- /dev/null +++ b/test/files/neg/elide-to-nothing.check @@ -0,0 +1,4 @@ +elide-to-nothing.scala:14: error: Cannot elide where Nothing is required. + val b: Nothing = unimplemented() + ^ +one error found diff --git a/test/files/neg/elide-to-nothing.flags b/test/files/neg/elide-to-nothing.flags new file mode 100644 index 0000000000..59a512e547 --- /dev/null +++ b/test/files/neg/elide-to-nothing.flags @@ -0,0 +1 @@ +-Xelide-below 500 diff --git a/test/files/neg/elide-to-nothing.scala b/test/files/neg/elide-to-nothing.scala new file mode 100644 index 0000000000..5008e8bc1d --- /dev/null +++ b/test/files/neg/elide-to-nothing.scala @@ -0,0 +1,31 @@ + +/** Test which should fail compilation */ +class ElysianFailed { + + import ElysianField._ + + // fine + val a: Int = myInt + + // fine + unimplemented() + + // not fine + val b: Nothing = unimplemented() + +} + +object ElysianField { + + import annotation.elidable + + @elidable(100) def unimplemented(): Nothing = throw new UnsupportedOperationException + + @elidable(100) def myInt: Int = 17 + +} + + + + + |