summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/javac/JavaParsers.scala
diff options
context:
space:
mode:
Diffstat (limited to 'src/compiler/scala/tools/nsc/javac/JavaParsers.scala')
-rw-r--r--src/compiler/scala/tools/nsc/javac/JavaParsers.scala45
1 files changed, 22 insertions, 23 deletions
diff --git a/src/compiler/scala/tools/nsc/javac/JavaParsers.scala b/src/compiler/scala/tools/nsc/javac/JavaParsers.scala
index 0388df7005..3c9cdbf878 100644
--- a/src/compiler/scala/tools/nsc/javac/JavaParsers.scala
+++ b/src/compiler/scala/tools/nsc/javac/JavaParsers.scala
@@ -378,8 +378,11 @@ trait JavaParsers extends JavaScanners {
def modifiers(inInterface: Boolean): Modifiers = {
var flags: Long = Flags.JAVA
// assumed true unless we see public/private/protected - see bug #1240
- var privateWithin: Name =
- if (inInterface) nme.EMPTY.toTypeName else thisPackageName
+ // Todo: look at pos/t1176, #1240, #1840, #1842, see what current access issues are.
+ var isPackageAccess = true
+ var annots: List[Tree] = Nil
+ def addAnnot(sym: Symbol) =
+ annots :+= New(TypeTree(sym.tpe), List(Nil))
while (true) {
in.token match {
@@ -387,15 +390,14 @@ trait JavaParsers extends JavaScanners {
in.nextToken
annotation()
case PUBLIC =>
- privateWithin = nme.EMPTY.toTypeName
+ isPackageAccess = false
in.nextToken
case PROTECTED =>
flags |= Flags.PROTECTED
- //privateWithin = thisPackageName
in.nextToken
case PRIVATE =>
+ isPackageAccess = false
flags |= Flags.PRIVATE
- privateWithin = nme.EMPTY.toTypeName
in.nextToken
case STATIC =>
flags |= Flags.STATIC
@@ -406,26 +408,23 @@ trait JavaParsers extends JavaScanners {
case FINAL =>
flags |= Flags.FINAL
in.nextToken
- case NATIVE | SYNCHRONIZED | TRANSIENT | VOLATILE | STRICTFP =>
+ case NATIVE =>
+ addAnnot(NativeAttr)
+ in.nextToken
+ case TRANSIENT =>
+ addAnnot(TransientAttr)
+ in.nextToken
+ case VOLATILE =>
+ addAnnot(VolatileAttr)
+ in.nextToken
+ case SYNCHRONIZED | STRICTFP =>
in.nextToken
case _ =>
- // XXX both these checks are definitely necessary, which would
- // seem to indicate the empty package situation needs review
- // def isEmptyPkg() =
- // privateWithin == nme.EMPTY.toTypeName ||
- // privateWithin == nme.EMPTY_PACKAGE_NAME_tn
- // XXX I think this test should just be "if (defaultAccess)"
- // but then many cases like pos/t1176 fail because scala code
- // with no package cannot access java code with no package.
- // if (defaultAccess && !isEmptyPkg)
- // flags |= Flags.PROTECTED // package private
-
- // my every attempt so far has left some combination of
- // #1240, #1840, #1842, or other java/scala mixes failing.
- // Reverting to original code, which means #1240 won't
- // work but other variations should.
-
- return Modifiers(flags, privateWithin)
+ val privateWithin: Name =
+ if (isPackageAccess && !inInterface) thisPackageName
+ else nme.EMPTY.toTypeName
+
+ return Modifiers(flags, privateWithin) withAnnotations annots
}
}
abort("should not be here")