Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Scalaxy/Privacy: batch flag tests

  • Loading branch information...
commit ed09f7ca02c6bf9cd08a7fea08c8dc957aa4d61d 1 parent 082fa57
@ochafik ochafik authored
View
2  Parano/src/main/scala/scalaxy/ParanoChecks.scala
@@ -81,7 +81,7 @@ trait ParanoChecks {
val sym = tree.symbol
if (tree.isInstanceOf[RefTree] &&
- sym.annotations.exists(a => Option(a.tpe).exists(_ =:= typeOf[scala.deprecated]))) {
+ sym.annotations.exists(a => Option(a.tpe).exists(_ =:= typeOf[scala.deprecated]))) {
error(tree.pos, s"$sym is deprecated")
}
View
2  Privacy/examples/Test.scala
@@ -5,6 +5,8 @@ object Test {
}
val foo = Foo(10, 12)
+ println(foo.theFirst)
+ println(foo.second)
println(foo.pubVal)
println(foo.privVal)
}
View
18 Privacy/src/main/scala/scalaxy/privacy/PrivacyComponent.scala
@@ -28,6 +28,13 @@ class PrivacyComponent(
override val runsAfter = runsRightAfter.toList
override val runsBefore = List[String]("namer")
+ private val flagsThatPreventPrivatization = {
+ import Flags._
+ PRIVATE | PROTECTED |
+ OVERRIDE | ABSTRACT | SYNTHETIC |
+ CASEACCESSOR | PARAMACCESSOR | PARAM | MACRO
+ }
+
def newPhase(prev: Phase): StdPhase = new StdPhase(prev) {
def apply(unit: CompilationUnit) {
unit.body = new Transformer {
@@ -37,19 +44,12 @@ class PrivacyComponent(
case _ =>
false
}
+
def shouldPrivatize(mods: Modifiers, name: Name): Boolean = {
val n = name.toString
name != nme.CONSTRUCTOR &&
- !mods.hasFlag(Flags.CASEACCESSOR) &&
- !mods.hasFlag(Flags.PARAMACCESSOR) &&
- !mods.hasFlag(Flags.PRIVATE) &&
- !mods.hasFlag(Flags.OVERRIDE) &&
- !mods.hasFlag(Flags.SYNTHETIC) &&
- !mods.hasFlag(Flags.PARAM) &&
- !mods.hasFlag(Flags.MACRO) &&
- !mods.hasFlag(Flags.ABSTRACT) &&
- !mods.hasFlag(Flags.PROTECTED) &&
+ mods.hasNoFlags(flagsThatPreventPrivatization) &&
!n.contains("$") && !n.matches("res\\d+") && // Special cases for the console.
!mods.annotations.exists(isPublicAnnotation _)
}
Please sign in to comment.
Something went wrong with that request. Please try again.