Making var arg kParameters default to empty array no argument given
fixes KT-29969
This commit is contained in:
committed by
Alexander Udalov
parent
b1dbacf45f
commit
34a64d9171
Generated
+10
@@ -22728,6 +22728,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
||||
runTest("compiler/testData/codegen/box/reflection/callBy/defaultInSuperInterface.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("emptyVarArg.kt")
|
||||
public void testEmptyVarArg() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/reflection/callBy/emptyVarArg.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("extensionFunction.kt")
|
||||
public void testExtensionFunction() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/reflection/callBy/extensionFunction.kt");
|
||||
@@ -23035,6 +23040,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
||||
runTest("compiler/testData/codegen/box/reflection/createAnnotation/callByKotlin.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("callByWithEmptyVarArg.kt")
|
||||
public void testCallByWithEmptyVarArg() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/reflection/createAnnotation/callByWithEmptyVarArg.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("callJava.kt")
|
||||
public void testCallJava() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/reflection/createAnnotation/callJava.kt");
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// IGNORE_BACKEND: JS_IR
|
||||
// IGNORE_BACKEND: JS, NATIVE
|
||||
|
||||
// WITH_REFLECT
|
||||
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
fun join(vararg strings: String) = strings.toList().joinToString("")
|
||||
|
||||
fun sum(vararg bytes: Byte) = bytes.toList().fold(0) { acc, el -> acc + el }
|
||||
|
||||
fun box(): String {
|
||||
val j = ::join
|
||||
val s = ::sum
|
||||
assertEquals("", j.callBy(emptyMap()))
|
||||
assertEquals(0, s.callBy(emptyMap()))
|
||||
return "OK"
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// IGNORE_BACKEND: JS_IR
|
||||
// IGNORE_BACKEND: JS, NATIVE
|
||||
|
||||
// WITH_REFLECT
|
||||
|
||||
import kotlin.reflect.*
|
||||
import kotlin.reflect.full.*
|
||||
import kotlin.test.assert
|
||||
|
||||
annotation class Foo(vararg val strings: String)
|
||||
|
||||
annotation class Bar(vararg val bytes: Byte)
|
||||
|
||||
fun box(): String {
|
||||
val fooConstructor = Foo::class.primaryConstructor!!
|
||||
val foo = fooConstructor.callBy(emptyMap())
|
||||
assert(foo.strings.isEmpty())
|
||||
|
||||
val barConstructor = Bar::class.primaryConstructor!!
|
||||
val bar = barConstructor.callBy(emptyMap())
|
||||
assert(bar.bytes.isEmpty())
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+10
@@ -24289,6 +24289,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
runTest("compiler/testData/codegen/box/reflection/callBy/defaultInSuperInterface.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("emptyVarArg.kt")
|
||||
public void testEmptyVarArg() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/reflection/callBy/emptyVarArg.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("extensionFunction.kt")
|
||||
public void testExtensionFunction() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/reflection/callBy/extensionFunction.kt");
|
||||
@@ -24596,6 +24601,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
runTest("compiler/testData/codegen/box/reflection/createAnnotation/callByKotlin.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("callByWithEmptyVarArg.kt")
|
||||
public void testCallByWithEmptyVarArg() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/reflection/createAnnotation/callByWithEmptyVarArg.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("callJava.kt")
|
||||
public void testCallJava() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/reflection/createAnnotation/callJava.kt");
|
||||
|
||||
+10
@@ -23106,6 +23106,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
runTest("compiler/testData/codegen/box/reflection/callBy/defaultInSuperInterface.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("emptyVarArg.kt")
|
||||
public void testEmptyVarArg() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/reflection/callBy/emptyVarArg.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("extensionFunction.kt")
|
||||
public void testExtensionFunction() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/reflection/callBy/extensionFunction.kt");
|
||||
@@ -23413,6 +23418,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
runTest("compiler/testData/codegen/box/reflection/createAnnotation/callByKotlin.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("callByWithEmptyVarArg.kt")
|
||||
public void testCallByWithEmptyVarArg() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/reflection/createAnnotation/callByWithEmptyVarArg.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("callJava.kt")
|
||||
public void testCallJava() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/reflection/createAnnotation/callJava.kt");
|
||||
|
||||
+10
@@ -22728,6 +22728,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
runTest("compiler/testData/codegen/box/reflection/callBy/defaultInSuperInterface.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("emptyVarArg.kt")
|
||||
public void testEmptyVarArg() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/reflection/callBy/emptyVarArg.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("extensionFunction.kt")
|
||||
public void testExtensionFunction() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/reflection/callBy/extensionFunction.kt");
|
||||
@@ -23035,6 +23040,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
runTest("compiler/testData/codegen/box/reflection/createAnnotation/callByKotlin.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("callByWithEmptyVarArg.kt")
|
||||
public void testCallByWithEmptyVarArg() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/reflection/createAnnotation/callByWithEmptyVarArg.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("callJava.kt")
|
||||
public void testCallJava() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/reflection/createAnnotation/callJava.kt");
|
||||
|
||||
Reference in New Issue
Block a user