summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJosh Suereth <Joshua.Suereth@gmail.com>2012-09-01 09:05:37 -0700
committerJosh Suereth <Joshua.Suereth@gmail.com>2012-09-01 09:05:37 -0700
commitf275cff8ddb75fd041b040a6f5c1e019a43a2bff (patch)
treeb6f7054d05a86ed05f2f1c305f3dfc7b8ae246e4 /src
parentc4d81e1e2de3c9724cce32dee4345298d46ef1cc (diff)
parent373f22a2022519ab894c1ea77460e6460d7c2ee4 (diff)
downloadscala-f275cff8ddb75fd041b040a6f5c1e019a43a2bff.tar.gz
scala-f275cff8ddb75fd041b040a6f5c1e019a43a2bff.tar.bz2
scala-f275cff8ddb75fd041b040a6f5c1e019a43a2bff.zip
Merge pull request #1201 from axel22/issue/4581
Fix SI-4581.
Diffstat (limited to 'src')
-rw-r--r--src/compiler/scala/tools/nsc/transform/CleanUp.scala10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/CleanUp.scala b/src/compiler/scala/tools/nsc/transform/CleanUp.scala
index 570704f049..972debb900 100644
--- a/src/compiler/scala/tools/nsc/transform/CleanUp.scala
+++ b/src/compiler/scala/tools/nsc/transform/CleanUp.scala
@@ -550,6 +550,10 @@ 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)
@@ -592,7 +596,8 @@ abstract class CleanUp extends Transform with ast.TreeDSL {
}
// create a static field in the companion class for this @static field
- val stfieldSym = linkedClass.newVariable(newTermName(name), tree.pos, STATIC | SYNTHETIC | FINAL) setInfo sym.tpe
+ val stfieldSym = linkedClass.newValue(newTermName(name), tree.pos, STATIC | SYNTHETIC | FINAL) setInfo sym.tpe
+ if (sym.isMutable) stfieldSym.setFlag(MUTABLE)
stfieldSym.addAnnotation(StaticClass)
val names = classNames.getOrElseUpdate(linkedClass, linkedClass.info.decls.collect {
@@ -768,7 +773,8 @@ abstract class CleanUp extends Transform with ast.TreeDSL {
staticSym <- clazz.info.decls
if staticSym.hasStaticAnnotation
} staticSym match {
- case stfieldSym if stfieldSym.isVariable =>
+ case stfieldSym if (stfieldSym.isValue && !stfieldSym.isMethod) || stfieldSym.isVariable =>
+ log(stfieldSym + " is value: " + stfieldSym.isValue)
val valdef = staticBodies((clazz, stfieldSym))
val ValDef(_, _, _, rhs) = valdef
val fixedrhs = rhs.changeOwner((valdef.symbol, clazz.info.decl(nme.CONSTRUCTOR)))