diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/files/neg/static-annot.check | 22 | ||||
-rw-r--r-- | test/files/neg/static-annot.scala | 53 | ||||
-rw-r--r-- | test/files/neg/t4581.check | 0 | ||||
-rw-r--r-- | test/files/neg/t4581/static-declaration_1.scala | 14 | ||||
-rw-r--r-- | test/files/neg/t4581/static_2.java | 15 | ||||
-rw-r--r-- | test/files/pos/t6294.scala | 14 | ||||
-rw-r--r-- | test/files/run/static-annot-repl.check | 38 | ||||
-rw-r--r-- | test/files/run/static-annot-repl.scala | 22 | ||||
-rw-r--r-- | test/files/run/static-annot/field.scala | 252 | ||||
-rw-r--r-- | test/files/run/t6236.check | 2 | ||||
-rw-r--r-- | test/files/run/t6236/file_1.scala | 9 | ||||
-rw-r--r-- | test/files/run/t6236/file_2.scala | 10 |
12 files changed, 0 insertions, 451 deletions
diff --git a/test/files/neg/static-annot.check b/test/files/neg/static-annot.check deleted file mode 100644 index c98e7d9658..0000000000 --- a/test/files/neg/static-annot.check +++ /dev/null @@ -1,22 +0,0 @@ -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: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 - ^ -7 errors found diff --git a/test/files/neg/static-annot.scala b/test/files/neg/static-annot.scala deleted file mode 100644 index c0b5ed30d8..0000000000 --- a/test/files/neg/static-annot.scala +++ /dev/null @@ -1,53 +0,0 @@ - - -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) -} - - -class StaticDef { - // this should not crash the compiler - @static def x = 42 -} diff --git a/test/files/neg/t4581.check b/test/files/neg/t4581.check deleted file mode 100644 index e69de29bb2..0000000000 --- a/test/files/neg/t4581.check +++ /dev/null diff --git a/test/files/neg/t4581/static-declaration_1.scala b/test/files/neg/t4581/static-declaration_1.scala deleted file mode 100644 index f9a66b29c1..0000000000 --- a/test/files/neg/t4581/static-declaration_1.scala +++ /dev/null @@ -1,14 +0,0 @@ - - - - - -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 deleted file mode 100644 index 2fd5bf1d82..0000000000 --- a/test/files/neg/t4581/static_2.java +++ /dev/null @@ -1,15 +0,0 @@ - - - - -public class static_2 { - public static void main(String[] args) { - Constants.Const = 17; - Constants.FinalConst = 99; - Constants.MutableField = 199; - } -} - - - - diff --git a/test/files/pos/t6294.scala b/test/files/pos/t6294.scala deleted file mode 100644 index c6d39a9cc8..0000000000 --- a/test/files/pos/t6294.scala +++ /dev/null @@ -1,14 +0,0 @@ - - - -object A { - @annotation.static final val x = 123 -} - - -object B { - println(A.x) -} - - - diff --git a/test/files/run/static-annot-repl.check b/test/files/run/static-annot-repl.check deleted file mode 100644 index 3a1532b823..0000000000 --- a/test/files/run/static-annot-repl.check +++ /dev/null @@ -1,38 +0,0 @@ -Type in expressions to have them evaluated. -Type :help for more information. - -scala> - -scala> import annotation.static -import annotation.static - -scala> @static var x1 = 42 -x1: Int = 42 - -scala> @static val x2 = 43 -x2: Int = 43 - -scala> @static def x3 = 44 -<console>:8: error: The @static annotation is not allowed on method definitions. - @static def x3 = 44 - ^ - -scala> x1 -res0: Int = 42 - -scala> x2 -res1: Int = 43 - -scala> x3 -<console>:9: error: not found: value x3 - x3 - ^ - -scala> class Test { - @static def x = 42 -} -<console>:9: error: The @static annotation is not allowed on method definitions. - @static def x = 42 - ^ - -scala>
\ No newline at end of file diff --git a/test/files/run/static-annot-repl.scala b/test/files/run/static-annot-repl.scala deleted file mode 100644 index 1d2e9b2d7e..0000000000 --- a/test/files/run/static-annot-repl.scala +++ /dev/null @@ -1,22 +0,0 @@ - - - -import scala.tools.partest.ReplTest - - - -object Test extends ReplTest { - def code = """ -import annotation.static -@static var x1 = 42 -@static val x2 = 43 -@static def x3 = 44 -x1 -x2 -x3 -class Test { - @static def x = 42 -} -""" - -} diff --git a/test/files/run/static-annot/field.scala b/test/files/run/static-annot/field.scala deleted file mode 100644 index 8408a51800..0000000000 --- a/test/files/run/static-annot/field.scala +++ /dev/null @@ -1,252 +0,0 @@ - - - -import java.lang.reflect.Modifier -import annotation.static -import reflect._ - - - -/* TEST 1 */ - -/* A @static-annotated field in the companion object should yield - * a static field in its companion class. - */ -object Foo { - @static val bar = 17 -} - - -class Foo - - -trait Check { - def checkStatic(cls: Class[_]) { - cls.getDeclaredFields.find(_.getName == "bar") match { - case Some(f) => - assert(Modifier.isStatic(f.getModifiers), "no static modifier") - case None => - assert(false, "no static field bar in class") - } - } - - def test(): Unit -} - - -object Test1 extends Check { - def test() { - checkStatic(classOf[Foo]) - assert(Foo.bar == 17, "Companion object field should be 17.") - } -} - - -/* TEST 2 */ - -class Foo2 - - -/** The order of declaring the class and its companion is inverted now. */ -object Foo2 { - @static val bar = 199 -} - - -object Test2 extends Check { - def test() { - checkStatic(Class.forName("Foo3")) - assert(Foo3.bar == 1984, "Companion object field should be 1984.") - } -} - - -/* TEST 3 */ - -/** The case where there is no explicit companion class */ -object Foo3 { - @static val bar = 1984 -} - - -object Test3 extends Check { - def test() { - checkStatic(Class.forName("Foo3")) - assert(Foo3.bar == 1984, "Companion object field should be 1984.") - } -} - - -/* TEST 4 */ - -/** We want to be able to generate atomic reference field updaters on the companion object - * so that they are created only once per class declaration, but we want them to actually - * be initialize __in the static initializer of the class itself__. - * This is extremely important, because otherwise the creation of the ARFU fails, since it uses - * trickery to detect the caller and compare it to the owner of the field being modified. - * Previously, this used to be circumvented through the use of Java base classes. A pain. - */ -class ArfuTarget { - @volatile var strfield = ArfuTarget.STR - - def CAS(ov: String, nv: String): Boolean = { - ArfuTarget.arfu.compareAndSet(this, ov, nv) - } -} - - -object ArfuTarget { - @static val arfu = java.util.concurrent.atomic.AtomicReferenceFieldUpdater.newUpdater(classOf[ArfuTarget], classOf[String], "strfield") - val STR = "Some string" -} - - -object Test4 extends Check { - def checkArfu() { - val at = new ArfuTarget - assert(at.strfield == ArfuTarget.STR) - at.CAS(ArfuTarget.STR, null) - assert(at.strfield == null) - } - - def test() { - checkArfu() - } -} - - -/* TEST 5 */ - -/** Although our main use-case is to use final static fields, we should be able to use non-final too. - * Here we set the static field of the class by using the setters in the companion object. - * It is legal to do so using the reference to `Foo` directly (in which case the callsites - * are rewritten to access the static field directly), or through an interface `Var` (in - * which case the getter and the setter for `field` access the static field in `Var`). - */ -trait Var { - var field: Int -} - -object VarHolder extends Var { - @static var field = 1 -} - - -object Test5 extends Check { - def test() { - assert(VarHolder.field == 1) - VarHolder.field = 2 - assert(VarHolder.field == 2) - val vh: Var = VarHolder - vh.field = 3 - assert(vh.field == 3) - } -} - - -/* TEST 6 */ - -/** Here we test flattening the static ctor body and changing the owners of local definitions. */ -object Foo6 { - var companionField = 101 - @static val staticField = { - val intermediate = companionField + 1 - intermediate * 2 - } -} - - -object Test6 extends Check { - def test() { - assert(Foo6.staticField == 204) - } -} - - - -/* TEST 7 */ - -/** Here we test objects nested in top-level objects */ -object Foo7 { - object AndHisFriend { - @static val bar = "string" - } - class AndHisFriend - - object AndHisLonelyFriend { - @static val bar = "another" - } -} - - -object Test7 extends Check { - def test() { - checkStatic(classOf[Foo7.AndHisFriend]) - assert(Foo7.AndHisFriend.bar == "string") - - checkStatic(Class.forName("Foo7$AndHisLonelyFriend")) - assert(Foo7.AndHisLonelyFriend.bar == "another") - } -} - - - -/* TEST 8 */ - -object Foo8 { - @static val field = 7 - - val function: () => Int = () => { - field + 1 - } - - val anon = new Runnable { - def run() { - assert(field == 7, "runnable asserting field is 7") - } - } - - @static var mutable = 10 - - val mutation: () => Unit = () => { - mutable += 1 - } -} - -object Test8 { - def test() { - assert(Foo8.function() == 8, "function must return 8") - Foo8.anon.run() - assert(Foo8.mutable == 10, "mutable is 10") - Foo8.mutation() - assert(Foo8.mutable == 11, "mutable is 11") - Foo8.mutation() - assert(Foo8.mutable == 12, "mutable is 12") - } -} - - - - -/* main */ - -object Test { - - def main(args: Array[String]) { - Test1.test() - Test2.test() - Test3.test() - Test4.test() - Test5.test() - Test6.test() - Test7.test() - Test8.test() - } - -} - - - - - - diff --git a/test/files/run/t6236.check b/test/files/run/t6236.check deleted file mode 100644 index a0a2e88d0a..0000000000 --- a/test/files/run/t6236.check +++ /dev/null @@ -1,2 +0,0 @@ -353 -353
\ No newline at end of file diff --git a/test/files/run/t6236/file_1.scala b/test/files/run/t6236/file_1.scala deleted file mode 100644 index 92d22799fc..0000000000 --- a/test/files/run/t6236/file_1.scala +++ /dev/null @@ -1,9 +0,0 @@ - - -package p { - object y { - object x { - @scala.annotation.static val foo: Int = 353 - } - } -} diff --git a/test/files/run/t6236/file_2.scala b/test/files/run/t6236/file_2.scala deleted file mode 100644 index 51823004ca..0000000000 --- a/test/files/run/t6236/file_2.scala +++ /dev/null @@ -1,10 +0,0 @@ - - - -object Test { - def main(args: Array[String]): Unit = { - println(p.y.x.foo) - println(p.y.x.foo) - } -} - |