From 227239018b38ab7218ee6b30493c9c8e1836c8c9 Mon Sep 17 00:00:00 2001 From: Aleksandar Date: Thu, 19 Jul 2012 14:33:07 +0200 Subject: WIP add private/lazy checks and a few tests. --- src/compiler/scala/tools/nsc/transform/CleanUp.scala | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/compiler') 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 => -- cgit v1.2.3