@@ -470,7 +470,8 @@ open class KotlinFileExtractor(
470470 idx : Int ,
471471 contextLabel : String? = null
472472 ): Label <out DbExpr > {
473- val t = useType(constructorCall.type)
473+ // Erase the type here because the JVM lowering erases the annotation type, and so the Java extractor will see it in erased form.
474+ val t = useType(erase(constructorCall.type))
474475 val annotationContextLabel = contextLabel ? : " {${t.javaResult.id} }"
475476 val id = tw.getLabelFor<DbDeclannotation >(" @\" annotation;{$parent };$annotationContextLabel \" " )
476477 tw.writeExprs_declannotation(id, t.javaResult.id, parent, idx)
@@ -485,8 +486,9 @@ open class KotlinFileExtractor(
485486 .filterIsInstance<IrProperty >()
486487 .first { it.name == param.name }
487488 val v = constructorCall.getValueArgument(i) ? : param.defaultValue?.expression
488- val getterId = useFunction<DbMethod >(prop.getter!! )
489- val exprId = extractAnnotationValueExpression(v, id, i, " {${getterId} }" )
489+ val getter = prop.getter!!
490+ val getterId = useFunction<DbMethod >(getter)
491+ val exprId = extractAnnotationValueExpression(v, id, i, " {${getterId} }" , getter.returnType)
490492 if (exprId != null ) {
491493 tw.writeAnnotValue(id, getterId, exprId)
492494 }
@@ -498,7 +500,8 @@ open class KotlinFileExtractor(
498500 v : IrExpression ? ,
499501 parent : Label <out DbExprparent >,
500502 idx : Int ,
501- contextLabel : String ): Label <out DbExpr >? {
503+ contextLabel : String ,
504+ contextType : IrType ? ): Label <out DbExpr >? {
502505
503506 fun exprId () = tw.getLabelFor<DbExpr >(" @\" annotationExpr;{$parent };$idx \" " )
504507
@@ -519,7 +522,10 @@ open class KotlinFileExtractor(
519522 }
520523 is IrVararg -> {
521524 tw.getLabelFor<DbArrayinit >(" @\" annotationarray;{${parent} };$contextLabel \" " ).also { arrayId ->
522- val type = useType(kClassToJavaClass(v.type))
525+ // Use the context type (i.e., the type the annotation expects, not the actual type of the array)
526+ // because the Java extractor fills in array types using the same technique. These should only
527+ // differ for generic annotations.
528+ val type = useType(kClassToJavaClass(contextType!! ))
523529 tw.writeExprs_arrayinit(arrayId, type.javaResult.id, parent, idx)
524530 tw.writeExprsKotlinType(arrayId, type.kotlinResult.id)
525531 tw.writeHasLocation(arrayId, tw.getLocation(v))
@@ -533,7 +539,7 @@ open class KotlinFileExtractor(
533539 null
534540 }
535541 }
536- extractAnnotationValueExpression(argExpr, arrayId, index, " child;$index " )
542+ extractAnnotationValueExpression(argExpr, arrayId, index, " child;$index " , null )
537543 } }
538544 }
539545 }
0 commit comments