diff options
author | Lukas Rytz <lukas.rytz@gmail.com> | 2014-10-20 14:03:43 +0200 |
---|---|---|
committer | Lukas Rytz <lukas.rytz@gmail.com> | 2014-10-20 14:09:12 +0200 |
commit | fa40ff3cd5edbf54eb2c77170f8d59861b372a5a (patch) | |
tree | 92554fd939ff73e785787c180cd38371e20d36d6 /src/compiler | |
parent | 2b5df373638d08204b71258928289f6b39e25d5f (diff) | |
download | scala-fa40ff3cd5edbf54eb2c77170f8d59861b372a5a.tar.gz scala-fa40ff3cd5edbf54eb2c77170f8d59861b372a5a.tar.bz2 scala-fa40ff3cd5edbf54eb2c77170f8d59861b372a5a.zip |
SI-8926 default visbility RUNTIME for java annotations
When parsed from source, java annotation class symbol are lacking the
`@Retention` annotation. In mixed compilation, java annotations are
therefore emitted with visibility CLASS.
This patch conservatively uses the RUNTIME visibility in case there is
no @Retention annotation.
The real solution is to fix the Java parser, logged in SI-8928.
Diffstat (limited to 'src/compiler')
-rw-r--r-- | src/compiler/scala/tools/nsc/backend/jvm/BCodeAsmCommon.scala | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/compiler/scala/tools/nsc/backend/jvm/BCodeAsmCommon.scala b/src/compiler/scala/tools/nsc/backend/jvm/BCodeAsmCommon.scala index 4285858bf8..fc01f89580 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/BCodeAsmCommon.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/BCodeAsmCommon.scala @@ -19,7 +19,7 @@ final class BCodeAsmCommon[G <: Global](val global: G) { val ExcludedForwarderFlags = { import scala.tools.nsc.symtab.Flags._ // Should include DEFERRED but this breaks findMember. - ( SPECIALIZED | LIFTED | PROTECTED | STATIC | EXPANDEDNAME | BridgeAndPrivateFlags | MACRO ) + SPECIALIZED | LIFTED | PROTECTED | STATIC | EXPANDEDNAME | BridgeAndPrivateFlags | MACRO } /** @@ -147,9 +147,16 @@ final class BCodeAsmCommon[G <: Global](val global: G) { annot.args.isEmpty } - def isRuntimeVisible(annot: AnnotationInfo): Boolean = - annot.atp.typeSymbol.getAnnotation(AnnotationRetentionAttr) - .exists(_.assocs.contains((nme.value -> LiteralAnnotArg(Constant(AnnotationRetentionPolicyRuntimeValue))))) + def isRuntimeVisible(annot: AnnotationInfo): Boolean = { + annot.atp.typeSymbol.getAnnotation(AnnotationRetentionAttr) match { + case Some(retentionAnnot) => + retentionAnnot.assocs.contains(nme.value -> LiteralAnnotArg(Constant(AnnotationRetentionPolicyRuntimeValue))) + case _ => + // SI-8926: if the annotation class symbol doesn't have a @RetentionPolicy annotation, the + // annotation is emitted with visibility `RUNTIME` + true + } + } private def retentionPolicyOf(annot: AnnotationInfo): Symbol = annot.atp.typeSymbol.getAnnotation(AnnotationRetentionAttr).map(_.assocs).map(assoc => |