diff options
author | Adriaan Moors <adriaan@lightbend.com> | 2016-12-19 15:30:54 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-12-19 15:30:54 -0800 |
commit | 56fb9172756d95ef903c36efcf54f1ae95c64b4b (patch) | |
tree | 5fd366037ff241337737cdd3ad9e8a31edb4e767 /test | |
parent | bba42ff5d410127c8fd9be0073a6eda91b8029d1 (diff) | |
parent | 582c8a2fdd1d5b3cacff982b0c4af0a7dd37b651 (diff) | |
download | scala-56fb9172756d95ef903c36efcf54f1ae95c64b4b.tar.gz scala-56fb9172756d95ef903c36efcf54f1ae95c64b4b.tar.bz2 scala-56fb9172756d95ef903c36efcf54f1ae95c64b4b.zip |
Merge pull request #5539 from som-snytt/issue/10068
SI-10068 Only permit elidable methods
Diffstat (limited to 'test')
-rw-r--r-- | test/files/neg/t10068.check | 13 | ||||
-rw-r--r-- | test/files/neg/t10068.flags | 1 | ||||
-rw-r--r-- | test/files/neg/t10068.scala | 9 | ||||
-rw-r--r-- | test/files/run/elidable.flags | 2 | ||||
-rw-r--r-- | test/files/run/elidable.scala | 21 |
5 files changed, 45 insertions, 1 deletions
diff --git a/test/files/neg/t10068.check b/test/files/neg/t10068.check new file mode 100644 index 0000000000..2bb27c4fd8 --- /dev/null +++ b/test/files/neg/t10068.check @@ -0,0 +1,13 @@ +t10068.scala:5: error: i : Only methods can be marked @elidable. + @elidable(INFO) val i: Int = 42 + ^ +t10068.scala:6: error: j: Only methods can be marked @elidable. + @elidable(INFO) lazy val j: Int = 42 + ^ +t10068.scala:7: error: k : Only methods can be marked @elidable. + @elidable(INFO) var k: Int = 42 + ^ +t10068.scala:9: error: D: Only methods can be marked @elidable. +@elidable(INFO) class D + ^ +four errors found diff --git a/test/files/neg/t10068.flags b/test/files/neg/t10068.flags new file mode 100644 index 0000000000..2b18795468 --- /dev/null +++ b/test/files/neg/t10068.flags @@ -0,0 +1 @@ +-Xelide-below WARNING -Xsource:2.13 diff --git a/test/files/neg/t10068.scala b/test/files/neg/t10068.scala new file mode 100644 index 0000000000..a45ee5dac4 --- /dev/null +++ b/test/files/neg/t10068.scala @@ -0,0 +1,9 @@ + +import annotation._, elidable._ + +class C { + @elidable(INFO) val i: Int = 42 + @elidable(INFO) lazy val j: Int = 42 + @elidable(INFO) var k: Int = 42 +} +@elidable(INFO) class D diff --git a/test/files/run/elidable.flags b/test/files/run/elidable.flags index 93fd3d5317..4bebebdc41 100644 --- a/test/files/run/elidable.flags +++ b/test/files/run/elidable.flags @@ -1 +1 @@ --Xelide-below 900 +-Xelide-below WARNING diff --git a/test/files/run/elidable.scala b/test/files/run/elidable.scala index 6a603084b7..02785972bb 100644 --- a/test/files/run/elidable.scala +++ b/test/files/run/elidable.scala @@ -1,6 +1,8 @@ import annotation._ import elidable._ +// runs -Xelide-below WARNING or 900 + trait T { @elidable(FINEST) def f1() @elidable(SEVERE) def f2() @@ -38,6 +40,13 @@ object Test { @elidable(FINEST) def fd() = 1.0 @elidable(FINEST) def fe() = "s" + /* variable elisions? see test/files/neg/t10068.scala + @elidable(INFO) val goner1: Int = { assert(false, "Should have been elided.") ; 42 } + @elidable(INFO) lazy val goner2: Int = { assert(false, "Should have been elided.") ; 42 } + @elidable(INFO) var goner3: Int = { assert(false, "Should have been elided.") ; 42 } + @elidable(INFO) var goner4: Nothing = _ + */ + def main(args: Array[String]): Unit = { f1() f2() @@ -80,5 +89,17 @@ object Test { Class.forName(className).getMethod(methodName) } } + + // variable elisions? + /* + assert(goner1 == 0) + assert(goner2 == 0) + assert(goner3 == 0) + try assert(goner4 == null) + catch { + case _: NullPointerException => println("NPE") + case _: NotImplementedError => println("NIE") + } + */ } } |