summaryrefslogtreecommitdiff
path: root/src/compiler
diff options
context:
space:
mode:
authorAleksandar <aleksandar@htpc.(none)>2012-07-19 14:33:07 +0200
committerAleksandar <aleksandar@htpc.(none)>2012-07-19 14:33:32 +0200
commit227239018b38ab7218ee6b30493c9c8e1836c8c9 (patch)
tree1ca54e040ce5cde7930bb51c553cc218c3fb05e8 /src/compiler
parent892ee3df93a10ffe24fb11b37ad7c3a9cb93d5de (diff)
downloadscala-227239018b38ab7218ee6b30493c9c8e1836c8c9.tar.gz
scala-227239018b38ab7218ee6b30493c9c8e1836c8c9.tar.bz2
scala-227239018b38ab7218ee6b30493c9c8e1836c8c9.zip
WIP add private/lazy checks and a few tests.
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/scala/tools/nsc/transform/CleanUp.scala11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/CleanUp.scala b/src/compiler/scala/tools/nsc/transform/CleanUp.scala
index 1d8d58ccf7..e672f1914a 100644
--- a/src/compiler/scala/tools/nsc/transform/CleanUp.scala
+++ b/src/compiler/scala/tools/nsc/transform/CleanUp.scala
@@ -566,12 +566,23 @@ abstract class CleanUp extends Transform with ast.TreeDSL {
val owner = sym.owner
val staticBeforeLifting = atPhase(currentRun.erasurePhase) { owner.isStatic }
+ val isPrivate = atPhase(currentRun.typerPhase) { sym.getter(owner).hasFlag(PRIVATE) }
+ val isProtected = atPhase(currentRun.typerPhase) { sym.getter(owner).hasFlag(PROTECTED) }
+ val isLazy = atPhase(currentRun.typerPhase) { sym.getter(owner).hasFlag(LAZY) }
if (!owner.isModuleClass || !staticBeforeLifting) {
if (!sym.isSynthetic) {
reporter.error(tree.pos, "Only members of top-level objects and their nested objects can be annotated with @static.")
tree.symbol.removeAnnotation(StaticClass)
}
super.transform(tree)
+ } else if (isPrivate || isProtected) {
+ reporter.error(tree.pos, "The @static annotation is only allowed on public members.")
+ tree.symbol.removeAnnotation(StaticClass)
+ super.transform(tree)
+ } else if (isLazy) {
+ reporter.error(tree.pos, "The @static annotation is not allowed on lazy members.")
+ tree.symbol.removeAnnotation(StaticClass)
+ super.transform(tree)
} else if (owner.isModuleClass) {
val linkedClass = owner.companionClass match {
case NoSymbol =>