@@ -628,14 +628,16 @@ open class KotlinFileExtractor(
628
628
private fun extractValueParameter (vp : IrValueParameter , parent : Label <out DbCallable >, idx : Int , typeSubstitution : TypeSubstitution ? , parentSourceDeclaration : Label <out DbCallable >, classTypeArgsIncludingOuterClasses : List <IrTypeArgument >? , extractTypeAccess : Boolean , locOverride : Label <DbLocation >? = null): TypeResults {
629
629
with (" value parameter" , vp) {
630
630
val location = locOverride ? : getLocation(vp, classTypeArgsIncludingOuterClasses)
631
- val maybeErasedType = (vp.parent as ? IrFunction )?.let {
631
+ val maybeAlteredType = (vp.parent as ? IrFunction )?.let {
632
632
if (overridesCollectionsMethodWithAlteredParameterTypes(it))
633
633
eraseCollectionsMethodParameterType(vp.type, it.name.asString(), idx)
634
+ else if ((vp.parent as ? IrConstructor )?.parentClassOrNull?.kind == ClassKind .ANNOTATION_CLASS )
635
+ kClassToJavaClass(vp.type)
634
636
else
635
637
null
636
638
} ? : vp.type
637
639
val javaType = (vp.parent as ? IrFunction )?.let { getJavaCallable(it)?.let { jCallable -> getJavaValueParameterType(jCallable, idx) } }
638
- val typeWithWildcards = addJavaLoweringWildcards(maybeErasedType , ! hasWildcardSuppressionAnnotation(vp), javaType)
640
+ val typeWithWildcards = addJavaLoweringWildcards(maybeAlteredType , ! hasWildcardSuppressionAnnotation(vp), javaType)
639
641
val substitutedType = typeSubstitution?.let { it(typeWithWildcards, TypeContext .OTHER , pluginContext) } ? : typeWithWildcards
640
642
val id = useValueParameter(vp, parent)
641
643
if (extractTypeAccess) {
@@ -734,14 +736,17 @@ open class KotlinFileExtractor(
734
736
val initializer: IrExpressionBody ?
735
737
val lhsType: TypeResults ?
736
738
val vId: Label <out DbVariable >?
739
+ val isAnnotationClassField: Boolean
737
740
if (f is IrField ) {
738
741
static = f.isStatic
739
742
initializer = f.initializer
740
- lhsType = useType(f.type)
743
+ isAnnotationClassField = isAnnotationClassField(f)
744
+ lhsType = useType(if (isAnnotationClassField) kClassToJavaClass(f.type) else f.type)
741
745
vId = useField(f)
742
746
} else if (f is IrEnumEntry ) {
743
747
static = true
744
748
initializer = f.initializerExpression
749
+ isAnnotationClassField = false
745
750
lhsType = getEnumEntryType(f)
746
751
if (lhsType == null ) {
747
752
return
@@ -762,7 +767,7 @@ open class KotlinFileExtractor(
762
767
tw.writeStmts_exprstmt(stmtId, blockAndFunctionId.first, idx++ , blockAndFunctionId.second)
763
768
tw.writeHasLocation(stmtId, declLocId)
764
769
val assignmentId = tw.getFreshIdLabel<DbAssignexpr >()
765
- val type = useType(expr.type)
770
+ val type = useType(if (isAnnotationClassField) kClassToJavaClass(expr.type) else expr.type)
766
771
tw.writeExprs_assignexpr(assignmentId, type.javaResult.id, stmtId, 0 )
767
772
tw.writeExprsKotlinType(assignmentId, type.kotlinResult.id)
768
773
tw.writeHasLocation(assignmentId, declLocId)
@@ -936,7 +941,8 @@ open class KotlinFileExtractor(
936
941
with (" field" , f) {
937
942
DeclarationStackAdjuster (f).use {
938
943
val fNameSuffix = getExtensionReceiverType(f)?.let { it.classFqName?.asString()?.replace(" ." , " $$" ) } ? : " "
939
- return extractField(useField(f), " ${f.name.asString()}$fNameSuffix " , f.type, parentId, tw.getLocation(f), f.visibility, f, isExternalDeclaration(f), f.isFinal)
944
+ val extractType = if (isAnnotationClassField(f)) kClassToJavaClass(f.type) else f.type
945
+ return extractField(useField(f), " ${f.name.asString()}$fNameSuffix " , extractType, parentId, tw.getLocation(f), f.visibility, f, isExternalDeclaration(f), f.isFinal)
940
946
}
941
947
}
942
948
}
@@ -2917,14 +2923,17 @@ open class KotlinFileExtractor(
2917
2923
if (owner is IrValueParameter && owner.index == - 1 && ! owner.isExtensionReceiver()) {
2918
2924
extractThisAccess(e, exprParent, callable)
2919
2925
} else {
2920
- extractVariableAccess(useValueDeclaration(owner), e.type, tw.getLocation(e), exprParent.parent, exprParent.idx, callable, exprParent.enclosingStmt)
2926
+ val isAnnotationClassParameter = ((owner as ? IrValueParameter )?.parent as ? IrConstructor )?.parentClassOrNull?.kind == ClassKind .ANNOTATION_CLASS
2927
+ val extractType = if (isAnnotationClassParameter) kClassToJavaClass(e.type) else e.type
2928
+ extractVariableAccess(useValueDeclaration(owner), extractType, tw.getLocation(e), exprParent.parent, exprParent.idx, callable, exprParent.enclosingStmt)
2921
2929
}
2922
2930
}
2923
2931
is IrGetField -> {
2924
2932
val exprParent = parent.expr(e, callable)
2925
2933
val owner = tryReplaceAndroidSyntheticField(e.symbol.owner)
2926
2934
val locId = tw.getLocation(e)
2927
- extractVariableAccess(useField(owner), e.type, locId, exprParent.parent, exprParent.idx, callable, exprParent.enclosingStmt).also { id ->
2935
+ val fieldType = if (isAnnotationClassField(owner)) kClassToJavaClass(e.type) else e.type
2936
+ extractVariableAccess(useField(owner), fieldType, locId, exprParent.parent, exprParent.idx, callable, exprParent.enclosingStmt).also { id ->
2928
2937
val receiver = e.receiver
2929
2938
if (receiver != null ) {
2930
2939
extractExpressionExpr(receiver, callable, id, - 1 , exprParent.enclosingStmt)
0 commit comments