diff options
author | Lukas Rytz <lukas.rytz@epfl.ch> | 2012-07-20 11:52:59 -0700 |
---|---|---|
committer | Lukas Rytz <lukas.rytz@epfl.ch> | 2012-07-20 11:52:59 -0700 |
commit | b67828d03908a3b94ca42404355b28f0f999eb89 (patch) | |
tree | 9349bcf56a28c3465e64cefc95bdaf88334296cd /test/files/neg | |
parent | 46da0ee29f380ccb455c9c3c2adcf375e0c13ccf (diff) | |
parent | 124f316b0813116c6574f60737e5b63f06f4329e (diff) | |
download | scala-b67828d03908a3b94ca42404355b28f0f999eb89.tar.gz scala-b67828d03908a3b94ca42404355b28f0f999eb89.tar.bz2 scala-b67828d03908a3b94ca42404355b28f0f999eb89.zip |
Merge pull request #894 from axel22/topic/static-annot-cherry-2.10.x
Implement @static annotation on singleton object fields.
Diffstat (limited to 'test/files/neg')
-rw-r--r-- | test/files/neg/static-annot.check | 19 | ||||
-rw-r--r-- | test/files/neg/static-annot.scala | 47 |
2 files changed, 66 insertions, 0 deletions
diff --git a/test/files/neg/static-annot.check b/test/files/neg/static-annot.check new file mode 100644 index 0000000000..66efebdcee --- /dev/null +++ b/test/files/neg/static-annot.check @@ -0,0 +1,19 @@ +static-annot.scala:8: error: Only members of top-level objects and their nested objects can be annotated with @static. + @static val bar = 1 + ^ +static-annot.scala:27: error: @static annotated field bar has the same name as a member of class Conflicting + @static val bar = 1 + ^ +static-annot.scala:37: error: The @static annotation is only allowed on public members. + @static private val bar = 1 + ^ +static-annot.scala:38: error: The @static annotation is only allowed on public members. + @static private val baz = 2 + ^ +static-annot.scala:39: error: The @static annotation is not allowed on lazy members. + @static lazy val bam = 3 + ^ +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 diff --git a/test/files/neg/static-annot.scala b/test/files/neg/static-annot.scala new file mode 100644 index 0000000000..c6c626d42b --- /dev/null +++ b/test/files/neg/static-annot.scala @@ -0,0 +1,47 @@ + + +import annotation.static + + + +class StaticInClass { + @static val bar = 1 +} + + +class NestedObjectInClass { + object Nested { + @static val blah = 2 + } +} + + +object NestedObjectInObject { + object Nested { + @static val succeed = 3 + } +} + + +object Conflicting { + @static val bar = 1 +} + + +class Conflicting { + val bar = 45 +} + + +object PrivateProtectedLazy { + @static private val bar = 1 + @static private val baz = 2 + @static lazy val bam = 3 +} + + +class PrivateProtectedLazy { + println(PrivateProtectedLazy.bar) + println(PrivateProtectedLazy.baz) + println(PrivateProtectedLazy.bam) +} |