diff options
author | Paul Phillips <paulp@improving.org> | 2012-02-22 19:54:36 -0800 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2012-02-22 20:09:40 -0800 |
commit | 06384c052ec31db4bd094b949bed0f3cb3fb644b (patch) | |
tree | 221fe6e2905ebfdf186cc7c828c729ea65450789 /test/files/neg | |
parent | a983f2b30c352f3d62f0ac615044dcd45b1b1618 (diff) | |
download | scala-06384c052ec31db4bd094b949bed0f3cb3fb644b.tar.gz scala-06384c052ec31db4bd094b949bed0f3cb3fb644b.tar.bz2 scala-06384c052ec31db4bd094b949bed0f3cb3fb644b.zip |
Reworked and restored elidable.
Found a better elidable implementation which is robust against other
parts of the compiler doing their things. Calls to elidable methods are
replaced with zero of the same type. Elidable methods themselves remain
in place, but with their body replaced with a zero of the method return
type.
Thus is everything to be found where it is expected to be found, but
nothing will be found where nothing ought to be found. Nothing of course
will never be found.
Diffstat (limited to 'test/files/neg')
-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 + +} + + + + + |