aboutsummaryrefslogtreecommitdiff
path: root/compiler/src/dotty/tools/backend
diff options
context:
space:
mode:
authorGuillaume Martres <smarter@ubuntu.com>2016-11-30 21:11:34 +0100
committerGuillaume Martres <smarter@ubuntu.com>2016-11-30 23:21:10 +0100
commita4fea264bd7348f930b47a9f3b08e94693e73564 (patch)
tree3f08bcf57008a3bae4815cd39ca2dde07b2189a7 /compiler/src/dotty/tools/backend
parentcaee63d62f5d4af3c78ec03a6ab34d87682f9522 (diff)
downloaddotty-a4fea264bd7348f930b47a9f3b08e94693e73564.tar.gz
dotty-a4fea264bd7348f930b47a9f3b08e94693e73564.tar.bz2
dotty-a4fea264bd7348f930b47a9f3b08e94693e73564.zip
Fix visibility of annotations
`isRuntimeVisible` and `retentionPolicyOf` had two different ways to get the retention policy of an annotation and they were both wrong. Fix retentionPolicyOf` and use it in `isRuntimeVisible`
Diffstat (limited to 'compiler/src/dotty/tools/backend')
-rw-r--r--compiler/src/dotty/tools/backend/jvm/DottyBackendInterface.scala20
1 files changed, 9 insertions, 11 deletions
diff --git a/compiler/src/dotty/tools/backend/jvm/DottyBackendInterface.scala b/compiler/src/dotty/tools/backend/jvm/DottyBackendInterface.scala
index 8a29cd5e2..6a4046dda 100644
--- a/compiler/src/dotty/tools/backend/jvm/DottyBackendInterface.scala
+++ b/compiler/src/dotty/tools/backend/jvm/DottyBackendInterface.scala
@@ -206,17 +206,15 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
implicit val ConstantClassTag: ClassTag[Constant] = ClassTag[Constant](classOf[Constant])
implicit val ClosureTag: ClassTag[Closure] = ClassTag[Closure](classOf[Closure])
- def isRuntimeVisible(annot: Annotation): Boolean = {
- annot.atp.typeSymbol.getAnnotation(AnnotationRetentionAttr) match {
- case Some(retentionAnnot) =>
- retentionAnnot.tree.find(_.symbol == AnnotationRetentionRuntimeAttr).isDefined
- case _ =>
- // SI-8926: if the annotation class symbol doesn't have a @RetentionPolicy annotation, the
- // annotation is emitted with visibility `RUNTIME`
- // dotty bug: #389
- true
+ def isRuntimeVisible(annot: Annotation): Boolean =
+ if (toDenot(annot.atp.typeSymbol).hasAnnotation(AnnotationRetentionAttr))
+ retentionPolicyOf(annot) == AnnotationRetentionRuntimeAttr
+ else {
+ // SI-8926: if the annotation class symbol doesn't have a @RetentionPolicy annotation, the
+ // annotation is emitted with visibility `RUNTIME`
+ // dotty bug: #389
+ true
}
- }
def shouldEmitAnnotation(annot: Annotation): Boolean = {
annot.symbol.isJavaDefined &&
@@ -226,7 +224,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
private def retentionPolicyOf(annot: Annotation): Symbol =
annot.atp.typeSymbol.getAnnotation(AnnotationRetentionAttr).
- flatMap(_.argument(0).map(_.symbol)).getOrElse(AnnotationRetentionClassAttr)
+ flatMap(_.argumentConstant(0).map(_.symbolValue)).getOrElse(AnnotationRetentionClassAttr)
private def emitArgument(av: AnnotationVisitor,
name: String,