FIR: recursive transform annotation if it has annotation as argument
#KT-42344 Fixed
This commit is contained in:
+12
-6
@@ -61,12 +61,16 @@ class IrConstTransformer(irBuiltIns: IrBuiltIns) : IrElementTransformerVoid() {
|
||||
|
||||
private fun transformAnnotations(annotationContainer: IrAnnotationContainer) {
|
||||
annotationContainer.annotations.forEach { annotation ->
|
||||
for (i in 0 until annotation.valueArgumentsCount) {
|
||||
val arg = annotation.getValueArgument(i) ?: continue
|
||||
when (arg) {
|
||||
is IrVararg -> annotation.putValueArgument(i, arg.transformVarArg())
|
||||
else -> annotation.putValueArgument(i, arg.transformSingleArg(annotation.symbol.owner.valueParameters[i].type))
|
||||
}
|
||||
transformAnnotation(annotation)
|
||||
}
|
||||
}
|
||||
|
||||
private fun transformAnnotation(annotation: IrConstructorCall) {
|
||||
for (i in 0 until annotation.valueArgumentsCount) {
|
||||
val arg = annotation.getValueArgument(i) ?: continue
|
||||
when (arg) {
|
||||
is IrVararg -> annotation.putValueArgument(i, arg.transformVarArg())
|
||||
else -> annotation.putValueArgument(i, arg.transformSingleArg(annotation.symbol.owner.valueParameters[i].type))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -92,6 +96,8 @@ class IrConstTransformer(irBuiltIns: IrBuiltIns) : IrElementTransformerVoid() {
|
||||
if (this.accept(IrCompileTimeChecker(mode = EvaluationMode.ONLY_BUILTINS), null)) {
|
||||
val const = interpreter.interpret(this).replaceIfError(this)
|
||||
return const.convertToConstIfPossible(expectedType)
|
||||
} else if (this is IrConstructorCall) {
|
||||
transformAnnotation(this)
|
||||
}
|
||||
return this
|
||||
}
|
||||
|
||||
+5
@@ -1717,6 +1717,11 @@ public class Fir2IrTextTestGenerated extends AbstractFir2IrTextTest {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/firProblems"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
||||
}
|
||||
|
||||
@TestMetadata("AnnotationInAnnotation.kt")
|
||||
public void testAnnotationInAnnotation() throws Exception {
|
||||
runTest("compiler/testData/ir/irText/firProblems/AnnotationInAnnotation.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("candidateSymbol.kt")
|
||||
public void testCandidateSymbol() throws Exception {
|
||||
runTest("compiler/testData/ir/irText/firProblems/candidateSymbol.kt");
|
||||
|
||||
Reference in New Issue
Block a user