Properly handle vararg interpretation for classic frontend
#KT-55108 Fixed
This commit is contained in:
+6
@@ -257,6 +257,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
|||||||
runTest("compiler/testData/codegen/box/annotations/kt25489.kt");
|
runTest("compiler/testData/codegen/box/annotations/kt25489.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt55108.kt")
|
||||||
|
public void testKt55108() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/annotations/kt55108.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("mustBeDocumented.kt")
|
@TestMetadata("mustBeDocumented.kt")
|
||||||
public void testMustBeDocumented() throws Exception {
|
public void testMustBeDocumented() throws Exception {
|
||||||
|
|||||||
+4
-8
@@ -119,14 +119,10 @@ class IrConstTransformer(
|
|||||||
if (elements.isEmpty()) return this
|
if (elements.isEmpty()) return this
|
||||||
val newIrVararg = IrVarargImpl(this.startOffset, this.endOffset, this.type, this.varargElementType)
|
val newIrVararg = IrVarargImpl(this.startOffset, this.endOffset, this.type, this.varargElementType)
|
||||||
for (element in this.elements) {
|
for (element in this.elements) {
|
||||||
when (element) {
|
when (val arg = (element as? IrSpreadElement)?.expression ?: element) {
|
||||||
is IrExpression -> newIrVararg.addElement(element.transformSingleArg(this.varargElementType))
|
is IrVararg -> arg.transformVarArg().elements.forEach { newIrVararg.addElement(it) }
|
||||||
is IrSpreadElement -> {
|
is IrExpression -> newIrVararg.addElement(arg.transformSingleArg(this.varargElementType))
|
||||||
when (val expression = element.expression) {
|
else -> newIrVararg.addElement(arg)
|
||||||
is IrVararg -> expression.transformVarArg().elements.forEach { newIrVararg.addElement(it) }
|
|
||||||
else -> newIrVararg.addElement(expression.transformSingleArg(this.varargElementType))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return newIrVararg
|
return newIrVararg
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
// TARGET_BACKEND: JVM_IR
|
||||||
|
// WITH_REFLECT
|
||||||
|
|
||||||
|
annotation class A(vararg val strings: String)
|
||||||
|
|
||||||
|
@A(*arrayOf("foo", "bar"), "baz")
|
||||||
|
class B
|
||||||
|
|
||||||
|
@A("baz", *arrayOf("foo", "bar"), "xyz")
|
||||||
|
class C
|
||||||
|
|
||||||
|
@A(*arrayOf("foo", "bar", "xyz"))
|
||||||
|
class D
|
||||||
|
|
||||||
|
@A("foo", "baz", "bar")
|
||||||
|
class E
|
||||||
|
|
||||||
|
@A(*arrayOf("foo", "bar"), *arrayOf("baz", "xyz"))
|
||||||
|
class F
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
assert((B::class.annotations.single() as A).strings.contentEquals(arrayOf("foo", "bar", "baz"))) { "Fail1" }
|
||||||
|
assert((C::class.annotations.single() as A).strings.contentEquals(arrayOf("baz", "foo", "bar", "xyz"))) { "Fail 2" }
|
||||||
|
assert((D::class.annotations.single() as A).strings.contentEquals(arrayOf("foo", "bar", "xyz"))) { "Fail 3" }
|
||||||
|
assert((E::class.annotations.single() as A).strings.contentEquals(arrayOf("foo", "baz", "bar"))) { "Fail 4" }
|
||||||
|
assert((F::class.annotations.single() as A).strings.contentEquals(arrayOf("foo", "bar", "baz", "xyz"))) { "Fail 5" }
|
||||||
|
return "OK"
|
||||||
|
}
|
||||||
+6
@@ -257,6 +257,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
|||||||
runTest("compiler/testData/codegen/box/annotations/kt25489.kt");
|
runTest("compiler/testData/codegen/box/annotations/kt25489.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt55108.kt")
|
||||||
|
public void testKt55108() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/annotations/kt55108.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("mustBeDocumented.kt")
|
@TestMetadata("mustBeDocumented.kt")
|
||||||
public void testMustBeDocumented() throws Exception {
|
public void testMustBeDocumented() throws Exception {
|
||||||
|
|||||||
Reference in New Issue
Block a user