@@ -208,7 +208,7 @@ open class KotlinFileExtractor(
208
208
is IrField -> {
209
209
val parentId = useDeclarationParent(getFieldParent(declaration), false )?.cast<DbReftype >()
210
210
if (parentId != null ) {
211
- extractField(declaration, parentId)
211
+ extractField(declaration, parentId, extractFunctionBodies )
212
212
}
213
213
Unit
214
214
}
@@ -480,21 +480,22 @@ open class KotlinFileExtractor(
480
480
extractDeclInitializers(c.declarations, false ) { Pair (blockId, obinitId) }
481
481
}
482
482
483
- private fun extractAnnotations (annotations : List <IrConstructorCall >, parent : Label <out DbExprparent >) {
483
+ private fun extractAnnotations (annotations : List <IrConstructorCall >, parent : Label <out DbExprparent >, extractEnumTypeAccesses : Boolean ) {
484
484
val groupedAnnotations = metaAnnotationSupport.groupRepeatableAnnotations(annotations)
485
485
for ((idx, constructorCall: IrConstructorCall ) in groupedAnnotations.sortedBy { v -> v.type.classFqName?.asString() }.withIndex()) {
486
- extractAnnotation(constructorCall, parent, idx)
486
+ extractAnnotation(constructorCall, parent, idx, extractEnumTypeAccesses )
487
487
}
488
488
}
489
489
490
- private fun extractAnnotations (c : IrAnnotationContainer , parent : Label <out DbExprparent >) {
491
- extractAnnotations(c.annotations, parent)
490
+ private fun extractAnnotations (c : IrAnnotationContainer , parent : Label <out DbExprparent >, extractEnumTypeAccesses : Boolean ) {
491
+ extractAnnotations(c.annotations, parent, extractEnumTypeAccesses )
492
492
}
493
493
494
494
private fun extractAnnotation (
495
495
constructorCall : IrConstructorCall ,
496
496
parent : Label <out DbExprparent >,
497
497
idx : Int ,
498
+ extractEnumTypeAccesses : Boolean ,
498
499
contextLabel : String? = null
499
500
): Label <out DbExpr > {
500
501
// Erase the type here because the JVM lowering erases the annotation type, and so the Java extractor will see it in erased form.
@@ -518,7 +519,7 @@ open class KotlinFileExtractor(
518
519
logger.warnElement(" Expected annotation property to define a getter" , prop)
519
520
} else {
520
521
val getterId = useFunction<DbMethod >(getter)
521
- val exprId = extractAnnotationValueExpression(v, id, i, " {${getterId} }" , getter.returnType)
522
+ val exprId = extractAnnotationValueExpression(v, id, i, " {${getterId} }" , getter.returnType, extractEnumTypeAccesses )
522
523
if (exprId != null ) {
523
524
tw.writeAnnotValue(id, getterId, exprId)
524
525
}
@@ -532,7 +533,8 @@ open class KotlinFileExtractor(
532
533
parent : Label <out DbExprparent >,
533
534
idx : Int ,
534
535
contextLabel : String ,
535
- contextType : IrType ? ): Label <out DbExpr >? {
536
+ contextType : IrType ? ,
537
+ extractEnumTypeAccesses : Boolean ): Label <out DbExpr >? {
536
538
537
539
fun exprId () = tw.getLabelFor<DbExpr >(" @\" annotationExpr;{$parent };$idx \" " )
538
540
@@ -541,15 +543,15 @@ open class KotlinFileExtractor(
541
543
extractConstant(v, parent, idx, null , null , overrideId = exprId())
542
544
}
543
545
is IrGetEnumValue -> {
544
- extractEnumValue(v, parent, idx, null , null , overrideId = exprId())
546
+ extractEnumValue(v, parent, idx, null , null , extractTypeAccess = extractEnumTypeAccesses, overrideId = exprId())
545
547
}
546
548
is IrClassReference -> {
547
549
val classRefId = exprId()
548
550
val typeAccessId = tw.getLabelFor<DbUnannotatedtypeaccess >(" @\" annotationExpr;{$classRefId };0\" " )
549
551
extractClassReference(v, parent, idx, null , null , overrideId = classRefId, typeAccessOverrideId = typeAccessId, useJavaLangClassType = true )
550
552
}
551
553
is IrConstructorCall -> {
552
- extractAnnotation(v, parent, idx, contextLabel)
554
+ extractAnnotation(v, parent, idx, extractEnumTypeAccesses, contextLabel)
553
555
}
554
556
is IrVararg -> {
555
557
tw.getLabelFor<DbArrayinit >(" @\" annotationarray;{${parent} };$contextLabel \" " ).also { arrayId ->
@@ -573,7 +575,7 @@ open class KotlinFileExtractor(
573
575
null
574
576
}
575
577
}
576
- extractAnnotationValueExpression(argExpr, arrayId, index, " child;$index " , null )
578
+ extractAnnotationValueExpression(argExpr, arrayId, index, " child;$index " , null , extractEnumTypeAccesses )
577
579
} }
578
580
}
579
581
}
@@ -682,11 +684,11 @@ open class KotlinFileExtractor(
682
684
683
685
val additionalAnnotations =
684
686
if (c.kind == ClassKind .ANNOTATION_CLASS && c.origin != IrDeclarationOrigin .IR_EXTERNAL_JAVA_DECLARATION_STUB )
685
- metaAnnotationSupport.generateJavaMetaAnnotations(c)
687
+ metaAnnotationSupport.generateJavaMetaAnnotations(c, extractFunctionBodies )
686
688
else
687
689
listOf ()
688
690
689
- extractAnnotations(c.annotations + additionalAnnotations, id)
691
+ extractAnnotations(c.annotations + additionalAnnotations, id, extractFunctionBodies )
690
692
691
693
if (extractFunctionBodies && ! c.isAnonymousObject && ! c.isLocal)
692
694
externalClassExtractor.writeStubTrapFile(c)
@@ -878,7 +880,7 @@ open class KotlinFileExtractor(
878
880
extractTypeAccessRecursive(substitutedType, location, id, - 1 )
879
881
}
880
882
val syntheticParameterNames = isUnderscoreParameter(vp) || ((vp.parent as ? IrFunction )?.let { hasSynthesizedParameterNames(it) } ? : true )
881
- extractAnnotations(vp, id)
883
+ extractAnnotations(vp, id, extractTypeAccess )
882
884
return extractValueParameter(id, substitutedType, vp.name.asString(), location, parent, idx, useValueParameter(vp, parentSourceDeclaration), syntheticParameterNames, vp.isVararg, vp.isNoinline, vp.isCrossinline)
883
885
}
884
886
}
@@ -1419,7 +1421,7 @@ open class KotlinFileExtractor(
1419
1421
linesOfCode?.linesOfCodeInDeclaration(f, id)
1420
1422
1421
1423
if (extractAnnotations)
1422
- extractAnnotations(f, id)
1424
+ extractAnnotations(f, id, extractMethodAndParameterTypeAccesses )
1423
1425
1424
1426
return id
1425
1427
}
@@ -1432,13 +1434,13 @@ open class KotlinFileExtractor(
1432
1434
&& f.symbol !is IrConstructorSymbol // not a constructor
1433
1435
}
1434
1436
1435
- private fun extractField (f : IrField , parentId : Label <out DbReftype >): Label <out DbField > {
1437
+ private fun extractField (f : IrField , parentId : Label <out DbReftype >, extractAnnotationEnumTypeAccesses : Boolean ): Label <out DbField > {
1436
1438
with (" field" , f) {
1437
1439
DeclarationStackAdjuster (f).use {
1438
1440
val fNameSuffix = getExtensionReceiverType(f)?.let { it.classFqName?.asString()?.replace(" ." , " $$" ) } ? : " "
1439
1441
val extractType = if (isAnnotationClassField(f)) kClassToJavaClass(f.type) else f.type
1440
1442
val id = useField(f)
1441
- extractAnnotations(f, id)
1443
+ extractAnnotations(f, id, extractAnnotationEnumTypeAccesses )
1442
1444
return extractField(id, " ${f.name.asString()}$fNameSuffix " , extractType, parentId, tw.getLocation(f), f.visibility, f, isExternalDeclaration(f), f.isFinal, isDirectlyExposedCompanionObjectField(f))
1443
1445
}
1444
1446
}
@@ -1522,7 +1524,7 @@ open class KotlinFileExtractor(
1522
1524
if (bf != null && extractBackingField) {
1523
1525
val fieldParentId = useDeclarationParent(getFieldParent(bf), false )
1524
1526
if (fieldParentId != null ) {
1525
- val fieldId = extractField(bf, fieldParentId.cast())
1527
+ val fieldId = extractField(bf, fieldParentId.cast(), extractFunctionBodies )
1526
1528
tw.writeKtPropertyBackingFields(id, fieldId)
1527
1529
if (p.isDelegated) {
1528
1530
tw.writeKtPropertyDelegates(id, fieldId)
@@ -1578,7 +1580,7 @@ open class KotlinFileExtractor(
1578
1580
extractDeclaration(it, extractPrivateMembers, extractFunctionBodies, extractAnnotations = true )
1579
1581
}
1580
1582
1581
- extractAnnotations(ee, id)
1583
+ extractAnnotations(ee, id, extractFunctionBodies )
1582
1584
}
1583
1585
}
1584
1586
}
@@ -4240,6 +4242,7 @@ open class KotlinFileExtractor(
4240
4242
idx : Int ,
4241
4243
enclosingCallable : Label <out DbCallable >? ,
4242
4244
enclosingStmt : Label <out DbStmt >? ,
4245
+ extractTypeAccess : Boolean = true,
4243
4246
overrideId : Label <out DbExpr >? = null
4244
4247
) =
4245
4248
exprIdOrFresh<DbVaraccess >(overrideId).also { id ->
@@ -4254,7 +4257,8 @@ open class KotlinFileExtractor(
4254
4257
val vId = useEnumEntry(owner)
4255
4258
tw.writeVariableBinding(id, vId)
4256
4259
4257
- extractStaticTypeAccessQualifier(owner, id, locId, enclosingCallable, enclosingStmt)
4260
+ if (extractTypeAccess)
4261
+ extractStaticTypeAccessQualifier(owner, id, locId, enclosingCallable, enclosingStmt)
4258
4262
4259
4263
}
4260
4264
}
0 commit comments