FIR: handle named argument properly during annotation serialization

This commit is contained in:
Mikhail Glukhikh
2021-08-31 16:25:39 +03:00
committed by TeamCityServer
parent 9620279201
commit 9c8b8f053e
4 changed files with 45 additions and 0 deletions
@@ -97,4 +97,8 @@ internal object FirToConstantValueTransformer : FirDefaultVisitor<ConstantValue<
): ConstantValue<*> {
return ArrayValue(varargArgumentsExpression.arguments.mapNotNull { it.accept(this, null) })
}
override fun visitNamedArgumentExpression(namedArgumentExpression: FirNamedArgumentExpression, data: Nothing?): ConstantValue<*>? {
return namedArgumentExpression.expression.accept(this, null)
}
}
@@ -16118,6 +16118,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
runTest("compiler/testData/codegen/box/fir/NameHighlighter.kt");
}
@Test
@TestMetadata("namedArgumentOnTypeAnnotation.kt")
public void testNamedArgumentOnTypeAnnotation() throws Exception {
runTest("compiler/testData/codegen/box/fir/namedArgumentOnTypeAnnotation.kt");
}
@Test
@TestMetadata("noSymbolForIntRangeIterator.kt")
public void testNoSymbolForIntRangeIterator() throws Exception {
@@ -0,0 +1,29 @@
// TARGET_BACKEND: JVM_IR
// FILE: Nls.java
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Documented
@Retention(RetentionPolicy.CLASS)
@Target({ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER, ElementType.LOCAL_VARIABLE, ElementType.TYPE_USE, ElementType.TYPE, ElementType.PACKAGE})
public @interface Nls {
enum Capitalization {
NotSpecified,
Title,
Sentence
}
Capitalization capitalization() default Capitalization.NotSpecified;
}
// FILE: box.kt
fun foo(arg: @Nls(capitalization = Nls.Capitalization.Sentence) String) = arg
fun box() = foo("OK")
@@ -16118,6 +16118,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
runTest("compiler/testData/codegen/box/fir/NameHighlighter.kt");
}
@Test
@TestMetadata("namedArgumentOnTypeAnnotation.kt")
public void testNamedArgumentOnTypeAnnotation() throws Exception {
runTest("compiler/testData/codegen/box/fir/namedArgumentOnTypeAnnotation.kt");
}
@Test
@TestMetadata("noSymbolForIntRangeIterator.kt")
public void testNoSymbolForIntRangeIterator() throws Exception {