summaryrefslogtreecommitdiff
path: root/src/compiler
diff options
context:
space:
mode:
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 =>