diff options
author | Paul Phillips <paulp@improving.org> | 2010-10-12 23:46:50 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2010-10-12 23:46:50 +0000 |
commit | 08c460450aaa1c3e3e6eb6b2b12309f1476bf6df (patch) | |
tree | 4807b1f6e607e59c360071f6c180eb36ec1c146e /src/compiler/scala/tools/nsc/javac | |
parent | 46d5e73c11bccd0e892429e4c3f2ac1a02cea2a9 (diff) | |
download | scala-08c460450aaa1c3e3e6eb6b2b12309f1476bf6df.tar.gz scala-08c460450aaa1c3e3e6eb6b2b12309f1476bf6df.tar.bz2 scala-08c460450aaa1c3e3e6eb6b2b12309f1476bf6df.zip |
This maps @native, @volatile, and @transient in...
This maps @native, @volatile, and @transient in java source to the
relevant annotations in scala, rather than discarding the modifiers
completely. I have no specific motivation for this other than it seems
better to do it than not. Also cleans up some old flailing of mine in
the dept. of mapping java access to scala. No review.
Diffstat (limited to 'src/compiler/scala/tools/nsc/javac')
-rw-r--r-- | src/compiler/scala/tools/nsc/javac/JavaParsers.scala | 45 |
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") |