Fix callable reference adaptation for vararg in fake override
`mappedVarargElements` are populated with parameters from `argumentMapping`, which is computed using `ArgumentsToParametersMapper` which calls `original` on all value parameters (see ArgumentsToParametersMapper.kt:136). So the code that adds empty lists for unassigned vararg parameters should also call `original`. Otherwise, in the added test, we ended up with two arguments for the parameter `s` in `id(::base1)`, one for `Base.s` containing the correct value, and another for `Derived.s` containing the empty list. Psi2ir took the last one, which resulted in empty array being passed to the vararg parameter. Note that all of this is caused by the fact that `original` of a fake override parameter is the parameter of the base function. This seems suspicious because `original` of a fake override _function_ is that fake override itself (NOT the base function), but this would probably be very risky to change at this point. #KT-48835 Fixed
This commit is contained in:
js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java
Generated
+5
@@ -1816,6 +1816,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes
|
||||
runTest("compiler/testData/codegen/box/callableReference/adaptedReferences/unboundReferences.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("varargFromBaseClass.kt")
|
||||
public void testVarargFromBaseClass() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/callableReference/adaptedReferences/varargFromBaseClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("varargViewedAsArray.kt")
|
||||
public void testVarargViewedAsArray() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/callableReference/adaptedReferences/varargViewedAsArray.kt");
|
||||
|
||||
Generated
+5
@@ -1816,6 +1816,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/callableReference/adaptedReferences/unboundReferences.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("varargFromBaseClass.kt")
|
||||
public void testVarargFromBaseClass() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/callableReference/adaptedReferences/varargFromBaseClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("varargViewedAsArray.kt")
|
||||
public void testVarargViewedAsArray() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/callableReference/adaptedReferences/varargViewedAsArray.kt");
|
||||
|
||||
Generated
+5
@@ -1781,6 +1781,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/callableReference/adaptedReferences/unboundReferences.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("varargFromBaseClass.kt")
|
||||
public void testVarargFromBaseClass() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/callableReference/adaptedReferences/varargFromBaseClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("varargViewedAsArray.kt")
|
||||
public void testVarargViewedAsArray() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/callableReference/adaptedReferences/varargViewedAsArray.kt");
|
||||
|
||||
js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java
Generated
+5
@@ -1616,6 +1616,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
|
||||
runTest("compiler/testData/codegen/box/callableReference/adaptedReferences/unboundReferences.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("varargFromBaseClass.kt")
|
||||
public void testVarargFromBaseClass() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/callableReference/adaptedReferences/varargFromBaseClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("varargViewedAsArray.kt")
|
||||
public void testVarargViewedAsArray() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/callableReference/adaptedReferences/varargViewedAsArray.kt");
|
||||
|
||||
Reference in New Issue
Block a user