summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAleksandar Prokopec <axel22@gmail.com>2012-08-27 16:03:59 +0200
committerAleksandar Prokopec <axel22@gmail.com>2012-08-27 17:15:39 +0200
commit373f22a2022519ab894c1ea77460e6460d7c2ee4 (patch)
tree54a77d2414cfa80b6a3e878acb06b1b6526887f5 /test
parent5bdfddefd7ff13476185b67d869a92c6c9f94506 (diff)
downloadscala-373f22a2022519ab894c1ea77460e6460d7c2ee4.tar.gz
scala-373f22a2022519ab894c1ea77460e6460d7c2ee4.tar.bz2
scala-373f22a2022519ab894c1ea77460e6460d7c2ee4.zip
Fix SI-4581.
Specifically, the final flag on the generated static field is no longer ommitted. Fix 2 failing test-cases.
Diffstat (limited to 'test')
-rw-r--r--test/files/neg/static-annot.check5
-rw-r--r--test/files/neg/t4581.check0
-rw-r--r--test/files/neg/t4581/static-declaration_1.scala14
-rw-r--r--test/files/neg/t4581/static_2.java15
-rw-r--r--test/files/run/static-annot-repl.check12
5 files changed, 42 insertions, 4 deletions
diff --git a/test/files/neg/static-annot.check b/test/files/neg/static-annot.check
index 66efebdcee..c98e7d9658 100644
--- a/test/files/neg/static-annot.check
+++ b/test/files/neg/static-annot.check
@@ -13,7 +13,10 @@ static-annot.scala:38: error: The @static annotation is only allowed on public m
static-annot.scala:39: error: The @static annotation is not allowed on lazy members.
@static lazy val bam = 3
^
+static-annot.scala:52: error: The @static annotation is not allowed on method definitions.
+ @static def x = 42
+ ^
static-annot.scala:14: error: Only members of top-level objects and their nested objects can be annotated with @static.
@static val blah = 2
^
-6 errors found \ No newline at end of file
+7 errors found
diff --git a/test/files/neg/t4581.check b/test/files/neg/t4581.check
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/test/files/neg/t4581.check
diff --git a/test/files/neg/t4581/static-declaration_1.scala b/test/files/neg/t4581/static-declaration_1.scala
new file mode 100644
index 0000000000..f9a66b29c1
--- /dev/null
+++ b/test/files/neg/t4581/static-declaration_1.scala
@@ -0,0 +1,14 @@
+
+
+
+
+
+object Constants {
+ import scala.annotation.static
+ @static val Const: Int = 0 // should generate a static final field
+ @static final val FinalConst: Int = 0 // ditto
+ @static var MutableField: Int = 0 // should not be final
+}
+
+
+
diff --git a/test/files/neg/t4581/static_2.java b/test/files/neg/t4581/static_2.java
new file mode 100644
index 0000000000..2fd5bf1d82
--- /dev/null
+++ b/test/files/neg/t4581/static_2.java
@@ -0,0 +1,15 @@
+
+
+
+
+public class static_2 {
+ public static void main(String[] args) {
+ Constants.Const = 17;
+ Constants.FinalConst = 99;
+ Constants.MutableField = 199;
+ }
+}
+
+
+
+
diff --git a/test/files/run/static-annot-repl.check b/test/files/run/static-annot-repl.check
index d1029a9809..3a1532b823 100644
--- a/test/files/run/static-annot-repl.check
+++ b/test/files/run/static-annot-repl.check
@@ -13,7 +13,9 @@ scala> @static val x2 = 43
x2: Int = 43
scala> @static def x3 = 44
-x3: Int
+<console>:8: error: The @static annotation is not allowed on method definitions.
+ @static def x3 = 44
+ ^
scala> x1
res0: Int = 42
@@ -22,11 +24,15 @@ scala> x2
res1: Int = 43
scala> x3
-res2: Int = 44
+<console>:9: error: not found: value x3
+ x3
+ ^
scala> class Test {
@static def x = 42
}
-defined class Test
+<console>:9: error: The @static annotation is not allowed on method definitions.
+ @static def x = 42
+ ^
scala> \ No newline at end of file