summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrzegorz Kossakowski <grzegorz.kossakowski@gmail.com>2012-09-14 10:41:51 +0200
committerGrzegorz Kossakowski <grzegorz.kossakowski@gmail.com>2012-09-17 20:26:08 +0200
commit4ed7a60caf3648571de9a120e095f9cf3a0151c4 (patch)
tree1fa74c1b7723c7d26d48e76d5eccf47da1ebff93
parent10c9cf05b415e39a004fcf983117668db73f46e1 (diff)
downloadscala-4ed7a60caf3648571de9a120e095f9cf3a0151c4.tar.gz
scala-4ed7a60caf3648571de9a120e095f9cf3a0151c4.tar.bz2
scala-4ed7a60caf3648571de9a120e095f9cf3a0151c4.zip
Revert "Fix SI-4581."
This reverts commit 373f22a2022519ab894c1ea77460e6460d7c2ee4.
-rw-r--r--src/compiler/scala/tools/nsc/transform/CleanUp.scala10
-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
6 files changed, 6 insertions, 50 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/CleanUp.scala b/src/compiler/scala/tools/nsc/transform/CleanUp.scala
index dff9a65649..68a9510407 100644
--- a/src/compiler/scala/tools/nsc/transform/CleanUp.scala
+++ b/src/compiler/scala/tools/nsc/transform/CleanUp.scala
@@ -550,10 +550,6 @@ abstract class CleanUp extends Transform with ast.TreeDSL {
else tree
}
- case DefDef(mods, name, tps, vps, tp, rhs) if tree.symbol.hasStaticAnnotation =>
- reporter.error(tree.pos, "The @static annotation is not allowed on method definitions.")
- super.transform(tree)
-
case ValDef(mods, name, tpt, rhs) if tree.symbol.hasStaticAnnotation =>
def transformStaticValDef = {
log("moving @static valdef field: " + name + ", in: " + tree.symbol.owner)
@@ -596,8 +592,7 @@ abstract class CleanUp extends Transform with ast.TreeDSL {
}
// create a static field in the companion class for this @static field
- val stfieldSym = linkedClass.newValue(newTermName(name), tree.pos, STATIC | SYNTHETIC | FINAL) setInfo sym.tpe
- if (sym.isMutable) stfieldSym.setFlag(MUTABLE)
+ val stfieldSym = linkedClass.newVariable(newTermName(name), tree.pos, STATIC | SYNTHETIC | FINAL) setInfo sym.tpe
stfieldSym.addAnnotation(StaticClass)
val names = classNames.getOrElseUpdate(linkedClass, linkedClass.info.decls.collect {
@@ -773,8 +768,7 @@ abstract class CleanUp extends Transform with ast.TreeDSL {
staticSym <- clazz.info.decls
if staticSym.hasStaticAnnotation
} staticSym match {
- case stfieldSym if (stfieldSym.isValue && !stfieldSym.isMethod) || stfieldSym.isVariable =>
- log(stfieldSym + " is value: " + stfieldSym.isValue)
+ case stfieldSym if stfieldSym.isVariable =>
val valdef = staticBodies((clazz, stfieldSym))
val ValDef(_, _, _, rhs) = valdef
val fixedrhs = rhs.changeOwner((valdef.symbol, clazz.info.decl(nme.CONSTRUCTOR)))
diff --git a/test/files/neg/static-annot.check b/test/files/neg/static-annot.check
index c98e7d9658..66efebdcee 100644
--- a/test/files/neg/static-annot.check
+++ b/test/files/neg/static-annot.check
@@ -13,10 +13,7 @@ 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
^
-7 errors found
+6 errors found \ No newline at end of file
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/run/static-annot-repl.check b/test/files/run/static-annot-repl.check
index 3a1532b823..d1029a9809 100644
--- a/test/files/run/static-annot-repl.check
+++ b/test/files/run/static-annot-repl.check
@@ -13,9 +13,7 @@ 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
- ^
+x3: Int
scala> x1
res0: Int = 42
@@ -24,15 +22,11 @@ scala> x2
res1: Int = 43
scala> x3
-<console>:9: error: not found: value x3
- x3
- ^
+res2: Int = 44
scala> class Test {
@static def x = 42
}
-<console>:9: error: The @static annotation is not allowed on method definitions.
- @static def x = 42
- ^
+defined class Test
scala> \ No newline at end of file