@@ -130,7 +130,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
130
130
}
131
131
132
132
def isRuntimeVisible (annot : Annotation ): Boolean =
133
- if (toDenot(annotHelper( annot).atp .typeSymbol).hasAnnotation(AnnotationRetentionAttr ))
133
+ if (toDenot(annot.tree.tpe .typeSymbol).hasAnnotation(AnnotationRetentionAttr ))
134
134
retentionPolicyOf(annot) == AnnotationRetentionRuntimeAttr
135
135
else {
136
136
// SI-8926: if the annotation class symbol doesn't have a @RetentionPolicy annotation, the
@@ -141,12 +141,11 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
141
141
142
142
def shouldEmitAnnotation (annot : Annotation ): Boolean = {
143
143
annot.symbol.isJavaDefined &&
144
- retentionPolicyOf(annot) != AnnotationRetentionSourceAttr &&
145
- annot.args.isEmpty
144
+ retentionPolicyOf(annot) != AnnotationRetentionSourceAttr
146
145
}
147
146
148
147
private def retentionPolicyOf (annot : Annotation ): Symbol =
149
- annot.atp .typeSymbol.getAnnotation(AnnotationRetentionAttr ).
148
+ annot.tree.tpe .typeSymbol.getAnnotation(AnnotationRetentionAttr ).
150
149
flatMap(_.argumentConstant(0 ).map(_.symbolValue)).getOrElse(AnnotationRetentionClassAttr )
151
150
152
151
private def normalizeArgument (arg : Tree ): Tree = arg match {
@@ -234,8 +233,8 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
234
233
def emitAnnotations (cw : asm.ClassVisitor , annotations : List [Annotation ], bcodeStore : BCodeHelpers )
235
234
(innerClasesStore : bcodeStore.BCInnerClassGen ): Unit = {
236
235
for (annot <- annotations; if shouldEmitAnnotation(annot)) {
237
- val typ = annot.atp
238
- val assocs = annot.assocs
236
+ val typ = annot.tree.tpe
237
+ val assocs = assocsFromApply( annot.tree)
239
238
val av = cw.visitAnnotation(innerClasesStore.typeDescriptor(typ.asInstanceOf [bcodeStore.int.Type ]), isRuntimeVisible(annot))
240
239
emitAssocs(av, assocs, bcodeStore)(innerClasesStore)
241
240
}
@@ -251,8 +250,8 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
251
250
def emitAnnotations (mw : asm.MethodVisitor , annotations : List [Annotation ], bcodeStore : BCodeHelpers )
252
251
(innerClasesStore : bcodeStore.BCInnerClassGen ): Unit = {
253
252
for (annot <- annotations; if shouldEmitAnnotation(annot)) {
254
- val typ = annot.atp
255
- val assocs = annot.assocs
253
+ val typ = annot.tree.tpe
254
+ val assocs = assocsFromApply( annot.tree)
256
255
val av = mw.visitAnnotation(innerClasesStore.typeDescriptor(typ.asInstanceOf [bcodeStore.int.Type ]), isRuntimeVisible(annot))
257
256
emitAssocs(av, assocs, bcodeStore)(innerClasesStore)
258
257
}
@@ -261,8 +260,8 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
261
260
def emitAnnotations (fw : asm.FieldVisitor , annotations : List [Annotation ], bcodeStore : BCodeHelpers )
262
261
(innerClasesStore : bcodeStore.BCInnerClassGen ): Unit = {
263
262
for (annot <- annotations; if shouldEmitAnnotation(annot)) {
264
- val typ = annot.atp
265
- val assocs = annot.assocs
263
+ val typ = annot.tree.tpe
264
+ val assocs = assocsFromApply( annot.tree)
266
265
val av = fw.visitAnnotation(innerClasesStore.typeDescriptor(typ.asInstanceOf [bcodeStore.int.Type ]), isRuntimeVisible(annot))
267
266
emitAssocs(av, assocs, bcodeStore)(innerClasesStore)
268
267
}
@@ -274,8 +273,8 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
274
273
if (annotationss forall (_.isEmpty)) return
275
274
for ((annots, idx) <- annotationss.zipWithIndex;
276
275
annot <- annots) {
277
- val typ = annot.atp
278
- val assocs = annot.assocs
276
+ val typ = annot.tree.tpe
277
+ val assocs = assocsFromApply( annot.tree)
279
278
val pannVisitor : asm.AnnotationVisitor = jmethod.visitParameterAnnotation(idx, innerClasesStore.typeDescriptor(typ.asInstanceOf [bcodeStore.int.Type ]), isRuntimeVisible(annot))
280
279
emitAssocs(pannVisitor, assocs, bcodeStore)(innerClasesStore)
281
280
}
@@ -472,24 +471,6 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
472
471
def sourceFileFor (cu : CompilationUnit ): String = cu.source.file.name
473
472
474
473
475
-
476
- implicit def positionHelper (a : Position ): PositionHelper = new PositionHelper {
477
- def isDefined : Boolean = a.exists
478
- def line : Int = sourcePos(a).line + 1
479
- def finalPosition : Position = a
480
- }
481
-
482
-
483
- implicit def annotHelper (a : Annotation ): AnnotationHelper = new AnnotationHelper {
484
- def atp : Type = a.tree.tpe
485
-
486
- def assocs : List [(Name , Tree )] = assocsFromApply(a.tree)
487
-
488
- def symbol : Symbol = a.tree.symbol
489
-
490
- def args : List [Tree ] = List .empty // those arguments to scala-defined annotations. they are never emitted
491
- }
492
-
493
474
def assocsFromApply (tree : Tree ): List [(Name , Tree )] = {
494
475
tree match {
495
476
case Block (_, expr) => assocsFromApply(expr)
@@ -970,12 +951,6 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
970
951
}
971
952
972
953
973
- abstract class PositionHelper {
974
- def isDefined : Boolean
975
- def finalPosition : Position
976
- def line : Int
977
- }
978
-
979
954
abstract class ConstantHelper {
980
955
def tag : ConstantTag
981
956
def longValue : Long
@@ -1182,13 +1157,6 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
1182
1157
def getPrimitive (sym : Symbol ): Int
1183
1158
}
1184
1159
1185
- abstract class AnnotationHelper {
1186
- def atp : Type
1187
- def symbol : Symbol
1188
- def args : List [Tree ]
1189
- def assocs : List [(Name , /* ClassfileAnnotArg*/ Object )]
1190
- }
1191
-
1192
1160
abstract class Caches {
1193
1161
def recordCache [T <: Clearable ](cache : T ): T
1194
1162
def newWeakMap [K , V ](): collection.mutable.WeakHashMap [K , V ]
0 commit comments