JVM: Fix default parameter values handling
When we generate call for 'foo', we make decision about invoking a 'foo$default' too late, after the call arguments are generated. If 'foo' was an override, and base class (interface) was generic, 'foo' in base class could have a different Kotlin and JVM signature, so the arguments we generated could be generated wrong (primitive or inline class values instead of boxes, see KT-38680). Also, we always selected first base class in supertypes list, which caused KT-15971. Look into resolved call and see if we should actually call 'foo$default' instead of 'foo' when determining actual callable. Overrides can't introduce default parameter values, and override-equivalent inherited methods with default parameters is an error in a child class. Thus, if we are calling a class member function with a default parameters, there should be one and only one overridden function that has default parameter values and overrides nothing.
This commit is contained in:
Generated
+10
@@ -11123,6 +11123,16 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/kt38680.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt38680a.kt")
|
||||
public void testKt38680a() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/kt38680a.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt38680b.kt")
|
||||
public void testKt38680b() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/kt38680b.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("mangledDefaultParameterFunction.kt")
|
||||
public void testMangledDefaultParameterFunction() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/mangledDefaultParameterFunction.kt");
|
||||
|
||||
+10
@@ -11188,6 +11188,16 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/kt38680.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt38680a.kt")
|
||||
public void testKt38680a() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/kt38680a.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt38680b.kt")
|
||||
public void testKt38680b() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/kt38680b.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("mangledDefaultParameterFunction.kt")
|
||||
public void testMangledDefaultParameterFunction() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/mangledDefaultParameterFunction.kt");
|
||||
|
||||
Reference in New Issue
Block a user