Preventively allocate slots for additional default parameters
Otherwise they are corrupted by inline
This commit is contained in:
@@ -1002,12 +1002,19 @@ public class FunctionCodegen {
|
|||||||
capturedArgumentsCount++;
|
capturedArgumentsCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
int maskIndex = 0;
|
|
||||||
List<ValueParameterDescriptor> valueParameters = functionDescriptor.getValueParameters();
|
List<ValueParameterDescriptor> valueParameters = functionDescriptor.getValueParameters();
|
||||||
for (int index = 0; index < valueParameters.size(); index++) {
|
assert valueParameters.size() > 0 : "Expecting value parameters to generate default function " + functionDescriptor;
|
||||||
|
int firstMaskIndex = frameMap.enterTemp(Type.INT_TYPE);
|
||||||
|
for (int index = 1; index < valueParameters.size(); index++) {
|
||||||
if (index % Integer.SIZE == 0) {
|
if (index % Integer.SIZE == 0) {
|
||||||
maskIndex = frameMap.enterTemp(Type.INT_TYPE);
|
frameMap.enterTemp(Type.INT_TYPE);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
//default handler or constructor marker
|
||||||
|
frameMap.enterTemp(AsmTypes.OBJECT_TYPE);
|
||||||
|
|
||||||
|
for (int index = 0; index < valueParameters.size(); index++) {
|
||||||
|
int maskIndex = firstMaskIndex + index / Integer.SIZE;
|
||||||
ValueParameterDescriptor parameterDescriptor = valueParameters.get(index);
|
ValueParameterDescriptor parameterDescriptor = valueParameters.get(index);
|
||||||
Type type = mappedParameters.get(capturedArgumentsCount + index).getAsmType();
|
Type type = mappedParameters.get(capturedArgumentsCount + index).getAsmType();
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,53 @@
|
|||||||
|
// FILE: 1.kt
|
||||||
|
|
||||||
|
package test
|
||||||
|
|
||||||
|
fun calc() = "OK"
|
||||||
|
|
||||||
|
inline fun String.test() = this
|
||||||
|
|
||||||
|
fun test(
|
||||||
|
p1: String = "1",
|
||||||
|
p2: String = "2",
|
||||||
|
p3: String = "3",
|
||||||
|
p4: String = "4",
|
||||||
|
p5: String = "5",
|
||||||
|
p6: String = "6",
|
||||||
|
p7: String = "7",
|
||||||
|
p8: String = "8",
|
||||||
|
p9: String = "9",
|
||||||
|
p10: String = "10",
|
||||||
|
p11: String = "11",
|
||||||
|
p12: String = "12",
|
||||||
|
p13: String = "13",
|
||||||
|
p14: String = "O".test(),
|
||||||
|
p15: String = "15",
|
||||||
|
p16: String = "16",
|
||||||
|
p17: String = "17",
|
||||||
|
p18: String = "18",
|
||||||
|
p19: String = "19",
|
||||||
|
p20: String = "20",
|
||||||
|
p21: String = "21",
|
||||||
|
p22: String = "22",
|
||||||
|
p23: String = "23",
|
||||||
|
p24: String = "24",
|
||||||
|
p25: String = "25",
|
||||||
|
p26: String = "26",
|
||||||
|
p27: String = "27",
|
||||||
|
p28: String = "28",
|
||||||
|
p29: String = "29",
|
||||||
|
p30: String = "30",
|
||||||
|
p31: String = "31",
|
||||||
|
p32: String = "32",
|
||||||
|
p33: String = "K".test()
|
||||||
|
): String {
|
||||||
|
return p14 + p33
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: 2.kt
|
||||||
|
|
||||||
|
import test.*
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
return test()
|
||||||
|
}
|
||||||
+51
@@ -0,0 +1,51 @@
|
|||||||
|
// FILE: 1.kt
|
||||||
|
|
||||||
|
package test
|
||||||
|
|
||||||
|
fun calc() = "OK"
|
||||||
|
|
||||||
|
inline fun String.test() = this
|
||||||
|
|
||||||
|
class Test(
|
||||||
|
p1: String = "1",
|
||||||
|
p2: String = "2",
|
||||||
|
p3: String = "3",
|
||||||
|
p4: String = "4",
|
||||||
|
p5: String = "5",
|
||||||
|
p6: String = "6",
|
||||||
|
p7: String = "7",
|
||||||
|
p8: String = "8",
|
||||||
|
p9: String = "9",
|
||||||
|
p10: String = "10",
|
||||||
|
p11: String = "11",
|
||||||
|
p12: String = "12",
|
||||||
|
p13: String = "13",
|
||||||
|
val p14: String = "O".test(),
|
||||||
|
p15: String = "15",
|
||||||
|
p16: String = "16",
|
||||||
|
p17: String = "17",
|
||||||
|
p18: String = "18",
|
||||||
|
p19: String = "19",
|
||||||
|
p20: String = "20",
|
||||||
|
p21: String = "21",
|
||||||
|
p22: String = "22",
|
||||||
|
p23: String = "23",
|
||||||
|
p24: String = "24",
|
||||||
|
p25: String = "25",
|
||||||
|
p26: String = "26",
|
||||||
|
p27: String = "27",
|
||||||
|
p28: String = "28",
|
||||||
|
p29: String = "29",
|
||||||
|
p30: String = "30",
|
||||||
|
p31: String = "31",
|
||||||
|
p32: String = "32",
|
||||||
|
val p33: String = "K".test()
|
||||||
|
)
|
||||||
|
// FILE: 2.kt
|
||||||
|
|
||||||
|
import test.*
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
val test = Test()
|
||||||
|
return test.p14 + test.p33
|
||||||
|
}
|
||||||
+12
@@ -949,6 +949,18 @@ public class IrBlackBoxInlineCodegenTestGenerated extends AbstractIrBlackBoxInli
|
|||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
public static class DefaultValues extends AbstractIrBlackBoxInlineCodegenTest {
|
public static class DefaultValues extends AbstractIrBlackBoxInlineCodegenTest {
|
||||||
|
@TestMetadata("33Parameters.kt")
|
||||||
|
public void test33Parameters() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/defaultValues/33Parameters.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("33ParametersInConstructor.kt")
|
||||||
|
public void test33ParametersInConstructor() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/defaultValues/33ParametersInConstructor.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
public void testAllFilesPresentInDefaultValues() throws Exception {
|
public void testAllFilesPresentInDefaultValues() throws Exception {
|
||||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxInline/defaultValues"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxInline/defaultValues"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
||||||
}
|
}
|
||||||
|
|||||||
+12
@@ -949,6 +949,18 @@ public class IrCompileKotlinAgainstInlineKotlinTestGenerated extends AbstractIrC
|
|||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
public static class DefaultValues extends AbstractIrCompileKotlinAgainstInlineKotlinTest {
|
public static class DefaultValues extends AbstractIrCompileKotlinAgainstInlineKotlinTest {
|
||||||
|
@TestMetadata("33Parameters.kt")
|
||||||
|
public void test33Parameters() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/defaultValues/33Parameters.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("33ParametersInConstructor.kt")
|
||||||
|
public void test33ParametersInConstructor() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/defaultValues/33ParametersInConstructor.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
public void testAllFilesPresentInDefaultValues() throws Exception {
|
public void testAllFilesPresentInDefaultValues() throws Exception {
|
||||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxInline/defaultValues"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxInline/defaultValues"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -949,6 +949,18 @@ public class BlackBoxInlineCodegenTestGenerated extends AbstractBlackBoxInlineCo
|
|||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
public static class DefaultValues extends AbstractBlackBoxInlineCodegenTest {
|
public static class DefaultValues extends AbstractBlackBoxInlineCodegenTest {
|
||||||
|
@TestMetadata("33Parameters.kt")
|
||||||
|
public void test33Parameters() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/defaultValues/33Parameters.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("33ParametersInConstructor.kt")
|
||||||
|
public void test33ParametersInConstructor() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/defaultValues/33ParametersInConstructor.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
public void testAllFilesPresentInDefaultValues() throws Exception {
|
public void testAllFilesPresentInDefaultValues() throws Exception {
|
||||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxInline/defaultValues"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxInline/defaultValues"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
||||||
}
|
}
|
||||||
|
|||||||
+12
@@ -949,6 +949,18 @@ public class CompileKotlinAgainstInlineKotlinTestGenerated extends AbstractCompi
|
|||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
public static class DefaultValues extends AbstractCompileKotlinAgainstInlineKotlinTest {
|
public static class DefaultValues extends AbstractCompileKotlinAgainstInlineKotlinTest {
|
||||||
|
@TestMetadata("33Parameters.kt")
|
||||||
|
public void test33Parameters() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/defaultValues/33Parameters.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("33ParametersInConstructor.kt")
|
||||||
|
public void test33ParametersInConstructor() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/defaultValues/33ParametersInConstructor.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
public void testAllFilesPresentInDefaultValues() throws Exception {
|
public void testAllFilesPresentInDefaultValues() throws Exception {
|
||||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxInline/defaultValues"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxInline/defaultValues"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
||||||
}
|
}
|
||||||
|
|||||||
+12
@@ -32,6 +32,18 @@ import java.util.regex.Pattern;
|
|||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
public class InlineDefaultValuesTestsGenerated extends AbstractInlineDefaultValuesTests {
|
public class InlineDefaultValuesTestsGenerated extends AbstractInlineDefaultValuesTests {
|
||||||
|
@TestMetadata("33Parameters.kt")
|
||||||
|
public void test33Parameters() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/defaultValues/33Parameters.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("33ParametersInConstructor.kt")
|
||||||
|
public void test33ParametersInConstructor() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/defaultValues/33ParametersInConstructor.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
public void testAllFilesPresentInDefaultValues() throws Exception {
|
public void testAllFilesPresentInDefaultValues() throws Exception {
|
||||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxInline/defaultValues"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JS, true);
|
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxInline/defaultValues"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JS, true);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user