@@ -628,14 +628,16 @@ open class KotlinFileExtractor(
628628 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 {
629629 with (" value parameter" , vp) {
630630 val location = locOverride ? : getLocation(vp, classTypeArgsIncludingOuterClasses)
631- val maybeErasedType = (vp.parent as ? IrFunction )?.let {
631+ val maybeAlteredType = (vp.parent as ? IrFunction )?.let {
632632 if (overridesCollectionsMethodWithAlteredParameterTypes(it))
633633 eraseCollectionsMethodParameterType(vp.type, it.name.asString(), idx)
634+ else if ((vp.parent as ? IrConstructor )?.parentClassOrNull?.kind == ClassKind .ANNOTATION_CLASS )
635+ kClassToJavaClass(vp.type)
634636 else
635637 null
636638 } ? : vp.type
637639 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)
639641 val substitutedType = typeSubstitution?.let { it(typeWithWildcards, TypeContext .OTHER , pluginContext) } ? : typeWithWildcards
640642 val id = useValueParameter(vp, parent)
641643 if (extractTypeAccess) {
@@ -734,14 +736,17 @@ open class KotlinFileExtractor(
734736 val initializer: IrExpressionBody ?
735737 val lhsType: TypeResults ?
736738 val vId: Label <out DbVariable >?
739+ val isAnnotationClassField: Boolean
737740 if (f is IrField ) {
738741 static = f.isStatic
739742 initializer = f.initializer
740- lhsType = useType(f.type)
743+ isAnnotationClassField = isAnnotationClassField(f)
744+ lhsType = useType(if (isAnnotationClassField) kClassToJavaClass(f.type) else f.type)
741745 vId = useField(f)
742746 } else if (f is IrEnumEntry ) {
743747 static = true
744748 initializer = f.initializerExpression
749+ isAnnotationClassField = false
745750 lhsType = getEnumEntryType(f)
746751 if (lhsType == null ) {
747752 return
@@ -762,7 +767,7 @@ open class KotlinFileExtractor(
762767 tw.writeStmts_exprstmt(stmtId, blockAndFunctionId.first, idx++ , blockAndFunctionId.second)
763768 tw.writeHasLocation(stmtId, declLocId)
764769 val assignmentId = tw.getFreshIdLabel<DbAssignexpr >()
765- val type = useType(expr.type)
770+ val type = useType(if (isAnnotationClassField) kClassToJavaClass(expr.type) else expr.type)
766771 tw.writeExprs_assignexpr(assignmentId, type.javaResult.id, stmtId, 0 )
767772 tw.writeExprsKotlinType(assignmentId, type.kotlinResult.id)
768773 tw.writeHasLocation(assignmentId, declLocId)
@@ -936,7 +941,8 @@ open class KotlinFileExtractor(
936941 with (" field" , f) {
937942 DeclarationStackAdjuster (f).use {
938943 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)
940946 }
941947 }
942948 }
@@ -2917,14 +2923,17 @@ open class KotlinFileExtractor(
29172923 if (owner is IrValueParameter && owner.index == - 1 && ! owner.isExtensionReceiver()) {
29182924 extractThisAccess(e, exprParent, callable)
29192925 } 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)
29212929 }
29222930 }
29232931 is IrGetField -> {
29242932 val exprParent = parent.expr(e, callable)
29252933 val owner = tryReplaceAndroidSyntheticField(e.symbol.owner)
29262934 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 ->
29282937 val receiver = e.receiver
29292938 if (receiver != null ) {
29302939 extractExpressionExpr(receiver, callable, id, - 1 , exprParent.enclosingStmt)
0 commit comments