JVM_IR KT-44483 argument adaptation is already done in PSI2IR
This commit is contained in:
+6
@@ -2440,6 +2440,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
||||
runTest("compiler/testData/codegen/box/callableReference/kt37604.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt44483.kt")
|
||||
public void testKt44483() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/callableReference/kt44483.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("nested.kt")
|
||||
public void testNested() throws Exception {
|
||||
|
||||
-19
@@ -574,25 +574,6 @@ internal class FunctionReferenceLowering(private val context: JvmBackendContext)
|
||||
else
|
||||
irGet(receiver!!)
|
||||
|
||||
// If a vararg parameter corresponds to exactly one KFunction argument, which is an array, that array
|
||||
// is forwarded as is.
|
||||
//
|
||||
// fun f(x: (Int, Array<String>) -> String) = x(0, arrayOf("OK", "FAIL"))
|
||||
// fun h(i: Int, vararg xs: String) = xs[i]
|
||||
// f(::h)
|
||||
//
|
||||
parameter.isVararg && unboundIndex < argumentTypes.size && parameter.type == valueParameters[unboundIndex].type ->
|
||||
irGet(valueParameters[unboundIndex++])
|
||||
// In all other cases, excess arguments are packed into a new array.
|
||||
//
|
||||
// fun g(x: (Int, String, String) -> String) = x(0, "OK", "FAIL")
|
||||
// f(::h) == g(::h)
|
||||
//
|
||||
parameter.isVararg && (unboundIndex < argumentTypes.size || !parameter.hasDefaultValue()) ->
|
||||
irArray(parameter.type) {
|
||||
(unboundIndex until argumentTypes.size).forEach { +irGet(valueParameters[unboundIndex++]) }
|
||||
}
|
||||
|
||||
unboundIndex >= argumentTypes.size ->
|
||||
// Default value argument (this pass doesn't handle suspend functions, otherwise
|
||||
// it could also be the continuation argument)
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
fun useUnit(fn: () -> Unit) {
|
||||
fn.invoke()
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
// DONT_TARGET_EXACT_BACKEND: WASM
|
||||
// WITH_RUNTIME
|
||||
|
||||
fun <K, V> f(vararg p: Pair<K, V>): K = p[0].first
|
||||
|
||||
fun box(): String {
|
||||
// NB this is not an adapted function reference
|
||||
val f: (Array<out Pair<String, Int>>) -> String = ::f
|
||||
return f(arrayOf("OK" to 0))
|
||||
}
|
||||
+6
@@ -2440,6 +2440,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
runTest("compiler/testData/codegen/box/callableReference/kt37604.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt44483.kt")
|
||||
public void testKt44483() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/callableReference/kt44483.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("nested.kt")
|
||||
public void testNested() throws Exception {
|
||||
|
||||
+6
@@ -2440,6 +2440,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
runTest("compiler/testData/codegen/box/callableReference/kt37604.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt44483.kt")
|
||||
public void testKt44483() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/callableReference/kt44483.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("nested.kt")
|
||||
public void testNested() throws Exception {
|
||||
|
||||
+5
@@ -2145,6 +2145,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
runTest("compiler/testData/codegen/box/callableReference/kt37604.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt44483.kt")
|
||||
public void testKt44483() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/callableReference/kt44483.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nested.kt")
|
||||
public void testNested() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/callableReference/nested.kt");
|
||||
|
||||
js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java
Generated
+5
@@ -1460,6 +1460,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes
|
||||
runTest("compiler/testData/codegen/box/callableReference/kt37604.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt44483.kt")
|
||||
public void testKt44483() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/callableReference/kt44483.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nested.kt")
|
||||
public void testNested() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/callableReference/nested.kt");
|
||||
|
||||
Generated
+5
@@ -1460,6 +1460,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/callableReference/kt37604.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt44483.kt")
|
||||
public void testKt44483() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/callableReference/kt44483.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nested.kt")
|
||||
public void testNested() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/callableReference/nested.kt");
|
||||
|
||||
Generated
+5
@@ -1460,6 +1460,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/callableReference/kt37604.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt44483.kt")
|
||||
public void testKt44483() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/callableReference/kt44483.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nested.kt")
|
||||
public void testNested() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/callableReference/nested.kt");
|
||||
|
||||
Reference in New Issue
Block a user