Do not count receivers in default parameters mask
If we implement default function with default parameters in inline
class, the receivers will be added to parameter list
(see ac7538a269). But since they
are not present in source parameters, we should not count them when we
compute mask for default parameters.
#KT-49977 Fixed
This commit is contained in:
+34
@@ -20727,6 +20727,40 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/defaultParameterValues/kt27416.kt");
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/codegen/box/inlineClasses/defaultParameterValues/defaultWithDefaultParameter")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class DefaultWithDefaultParameter {
|
||||
@Test
|
||||
@TestMetadata("all.kt")
|
||||
public void testAll() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/defaultParameterValues/defaultWithDefaultParameter/all.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAllFilesPresentInDefaultWithDefaultParameter() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/inlineClasses/defaultParameterValues/defaultWithDefaultParameter"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("all-compatibility.kt")
|
||||
public void testAll_compatibility() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/defaultParameterValues/defaultWithDefaultParameter/all-compatibility.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("compatibility.kt")
|
||||
public void testCompatibility() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/defaultParameterValues/defaultWithDefaultParameter/compatibility.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("default.kt")
|
||||
public void testDefault() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/defaultParameterValues/defaultWithDefaultParameter/default.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/codegen/box/inlineClasses/defaultParameterValues/overrideFunctionWithDefaultParameter")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
|
||||
+1
-1
@@ -416,7 +416,7 @@ open class DefaultParameterInjector(
|
||||
listOfNotNull(stubFunction.dispatchReceiverParameter, stubFunction.extensionReceiverParameter)
|
||||
else emptyList()
|
||||
return stubFunction.symbol to (valueParametersPrefix + stubFunction.valueParameters).mapIndexed { i, parameter ->
|
||||
if (!parameter.isMovedReceiver()) {
|
||||
if (!parameter.isMovedReceiver() && parameter != stubFunction.dispatchReceiverParameter && parameter != stubFunction.extensionReceiverParameter) {
|
||||
++sourceParameterIndex
|
||||
}
|
||||
when {
|
||||
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
// WITH_STDLIB
|
||||
|
||||
// !JVM_DEFAULT_MODE: all-compatibility
|
||||
// TARGET_BACKEND: JVM
|
||||
// IGNORE_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
|
||||
interface Path {
|
||||
fun dispatch(s: String = "K") = "dispatch$s"
|
||||
fun Int.extension(s: String = "K") = "${this}extension$s"
|
||||
}
|
||||
|
||||
@JvmInline
|
||||
value class RealPath(val x: Int) : Path
|
||||
|
||||
fun box(): String {
|
||||
val rp = RealPath(1)
|
||||
val res = "${rp.dispatch()};${rp.dispatch("KK")};" +
|
||||
with(rp) {
|
||||
"${1.extension()};${2.extension("KK")}"
|
||||
}
|
||||
if (res != "dispatchK;dispatchKK;1extensionK;2extensionKK") return res
|
||||
return "OK"
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
// WITH_STDLIB
|
||||
|
||||
// !JVM_DEFAULT_MODE: all
|
||||
// TARGET_BACKEND: JVM
|
||||
// IGNORE_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
|
||||
interface Path {
|
||||
fun dispatch(s: String = "K") = "dispatch$s"
|
||||
fun Int.extension(s: String = "K") = "${this}extension$s"
|
||||
}
|
||||
|
||||
@JvmInline
|
||||
value class RealPath(val x: Int) : Path
|
||||
|
||||
fun box(): String {
|
||||
val rp = RealPath(1)
|
||||
val res = "${rp.dispatch()};${rp.dispatch("KK")};" +
|
||||
with(rp) {
|
||||
"${1.extension()};${2.extension("KK")}"
|
||||
}
|
||||
if (res != "dispatchK;dispatchKK;1extensionK;2extensionKK") return res
|
||||
return "OK"
|
||||
}
|
||||
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
// WITH_STDLIB
|
||||
|
||||
// !JVM_DEFAULT_MODE: compatibility
|
||||
// TARGET_BACKEND: JVM
|
||||
// IGNORE_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
|
||||
interface Path {
|
||||
fun dispatch(s: String = "K") = "dispatch$s"
|
||||
fun Int.extension(s: String = "K") = "${this}extension$s"
|
||||
}
|
||||
|
||||
@JvmInline
|
||||
value class RealPath(val x: Int) : Path
|
||||
|
||||
fun box(): String {
|
||||
val rp = RealPath(1)
|
||||
val res = "${rp.dispatch()};${rp.dispatch("KK")};" +
|
||||
with(rp) {
|
||||
"${1.extension()};${2.extension("KK")}"
|
||||
}
|
||||
if (res != "dispatchK;dispatchKK;1extensionK;2extensionKK") return res
|
||||
return "OK"
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
// WITH_STDLIB
|
||||
|
||||
// TARGET_BACKEND: JVM
|
||||
// IGNORE_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
|
||||
interface Path {
|
||||
fun dispatch(s: String = "K") = "dispatch$s"
|
||||
fun Int.extension(s: String = "K") = "${this}extension$s"
|
||||
}
|
||||
|
||||
@JvmInline
|
||||
value class RealPath(val x: Int) : Path
|
||||
|
||||
fun box(): String {
|
||||
val rp = RealPath(1)
|
||||
val res = "${rp.dispatch()};${rp.dispatch("KK")};" +
|
||||
with(rp) {
|
||||
"${1.extension()};${2.extension("KK")}"
|
||||
}
|
||||
if (res != "dispatchK;dispatchKK;1extensionK;2extensionKK") return res
|
||||
return "OK"
|
||||
}
|
||||
+1
-2
@@ -10,8 +10,7 @@ interface Path {
|
||||
fun Int.extension(maxDepth: Int = 42)
|
||||
}
|
||||
|
||||
@Suppress("OPTIONAL_DECLARATION_USAGE_IN_NON_COMMON_SOURCE")
|
||||
@kotlin.jvm.JvmInline
|
||||
@JvmInline
|
||||
value class RealPath(val x: Int) : Path {
|
||||
override fun dispatch(maxDepth: Int) = Unit
|
||||
|
||||
|
||||
+1
-2
@@ -10,8 +10,7 @@ interface Path {
|
||||
fun Int.extension(maxDepth: Int = 42)
|
||||
}
|
||||
|
||||
@Suppress("OPTIONAL_DECLARATION_USAGE_IN_NON_COMMON_SOURCE")
|
||||
@kotlin.jvm.JvmInline
|
||||
@JvmInline
|
||||
value class RealPath(val x: Int) : Path {
|
||||
override fun dispatch(maxDepth: Int) = Unit
|
||||
|
||||
|
||||
+1
-2
@@ -10,8 +10,7 @@ interface Path {
|
||||
fun Int.extension(maxDepth: Int = 42)
|
||||
}
|
||||
|
||||
@Suppress("OPTIONAL_DECLARATION_USAGE_IN_NON_COMMON_SOURCE")
|
||||
@kotlin.jvm.JvmInline
|
||||
@JvmInline
|
||||
value class RealPath(val x: Int) : Path {
|
||||
override fun dispatch(maxDepth: Int) = Unit
|
||||
|
||||
|
||||
+1
-2
@@ -9,8 +9,7 @@ interface Path {
|
||||
fun Int.extension(maxDepth: Int = 42)
|
||||
}
|
||||
|
||||
@Suppress("OPTIONAL_DECLARATION_USAGE_IN_NON_COMMON_SOURCE")
|
||||
@kotlin.jvm.JvmInline
|
||||
@JvmInline
|
||||
value class RealPath(val x: Int) : Path {
|
||||
override fun dispatch(maxDepth: Int) = Unit
|
||||
|
||||
|
||||
+34
@@ -20565,6 +20565,40 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/defaultParameterValues/kt27416.kt");
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/codegen/box/inlineClasses/defaultParameterValues/defaultWithDefaultParameter")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class DefaultWithDefaultParameter {
|
||||
@Test
|
||||
@TestMetadata("all.kt")
|
||||
public void testAll() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/defaultParameterValues/defaultWithDefaultParameter/all.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAllFilesPresentInDefaultWithDefaultParameter() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/inlineClasses/defaultParameterValues/defaultWithDefaultParameter"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("all-compatibility.kt")
|
||||
public void testAll_compatibility() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/defaultParameterValues/defaultWithDefaultParameter/all-compatibility.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("compatibility.kt")
|
||||
public void testCompatibility() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/defaultParameterValues/defaultWithDefaultParameter/compatibility.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("default.kt")
|
||||
public void testDefault() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/defaultParameterValues/defaultWithDefaultParameter/default.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/codegen/box/inlineClasses/defaultParameterValues/overrideFunctionWithDefaultParameter")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
|
||||
+34
@@ -20727,6 +20727,40 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/defaultParameterValues/kt27416.kt");
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/codegen/box/inlineClasses/defaultParameterValues/defaultWithDefaultParameter")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class DefaultWithDefaultParameter {
|
||||
@Test
|
||||
@TestMetadata("all.kt")
|
||||
public void testAll() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/defaultParameterValues/defaultWithDefaultParameter/all.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAllFilesPresentInDefaultWithDefaultParameter() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/inlineClasses/defaultParameterValues/defaultWithDefaultParameter"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("all-compatibility.kt")
|
||||
public void testAll_compatibility() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/defaultParameterValues/defaultWithDefaultParameter/all-compatibility.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("compatibility.kt")
|
||||
public void testCompatibility() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/defaultParameterValues/defaultWithDefaultParameter/compatibility.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("default.kt")
|
||||
public void testDefault() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/defaultParameterValues/defaultWithDefaultParameter/default.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/codegen/box/inlineClasses/defaultParameterValues/overrideFunctionWithDefaultParameter")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
|
||||
+33
@@ -17098,6 +17098,39 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/defaultParameterValues/kt27416.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/box/inlineClasses/defaultParameterValues/defaultWithDefaultParameter")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class DefaultWithDefaultParameter extends AbstractLightAnalysisModeTest {
|
||||
@TestMetadata("all.kt")
|
||||
public void ignoreAll() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/defaultParameterValues/defaultWithDefaultParameter/all.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("all-compatibility.kt")
|
||||
public void ignoreAll_compatibility() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/defaultParameterValues/defaultWithDefaultParameter/all-compatibility.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("compatibility.kt")
|
||||
public void ignoreCompatibility() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/defaultParameterValues/defaultWithDefaultParameter/compatibility.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("default.kt")
|
||||
public void ignoreDefault() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/defaultParameterValues/defaultWithDefaultParameter/default.kt");
|
||||
}
|
||||
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInDefaultWithDefaultParameter() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/inlineClasses/defaultParameterValues/defaultWithDefaultParameter"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true);
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/box/inlineClasses/defaultParameterValues/overrideFunctionWithDefaultParameter")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
|
||||
+10
@@ -16349,6 +16349,16 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/defaultParameterValues/kt27416.kt");
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/codegen/box/inlineClasses/defaultParameterValues/defaultWithDefaultParameter")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class DefaultWithDefaultParameter {
|
||||
@Test
|
||||
public void testAllFilesPresentInDefaultWithDefaultParameter() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/inlineClasses/defaultParameterValues/defaultWithDefaultParameter"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true);
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/codegen/box/inlineClasses/defaultParameterValues/overrideFunctionWithDefaultParameter")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
|
||||
+10
@@ -16313,6 +16313,16 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/defaultParameterValues/kt27416.kt");
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/codegen/box/inlineClasses/defaultParameterValues/defaultWithDefaultParameter")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class DefaultWithDefaultParameter {
|
||||
@Test
|
||||
public void testAllFilesPresentInDefaultWithDefaultParameter() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/inlineClasses/defaultParameterValues/defaultWithDefaultParameter"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true);
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/codegen/box/inlineClasses/defaultParameterValues/overrideFunctionWithDefaultParameter")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
|
||||
+13
@@ -13730,6 +13730,19 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/defaultParameterValues/kt27416.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/box/inlineClasses/defaultParameterValues/defaultWithDefaultParameter")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class DefaultWithDefaultParameter extends AbstractIrCodegenBoxWasmTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest0(this::doTest, TargetBackend.WASM, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInDefaultWithDefaultParameter() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/inlineClasses/defaultParameterValues/defaultWithDefaultParameter"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true);
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/box/inlineClasses/defaultParameterValues/overrideFunctionWithDefaultParameter")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
|
||||
+35
@@ -20939,6 +20939,41 @@ public class NativeExtBlackBoxTestGenerated extends AbstractNativeBlackBoxTest {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/defaultParameterValues/kt27416.kt");
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/codegen/box/inlineClasses/defaultParameterValues/defaultWithDefaultParameter")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@NativeBlackBoxTestCaseGroupProvider(ExtTestCaseGroupProvider.class)
|
||||
public class DefaultWithDefaultParameter {
|
||||
@Test
|
||||
@TestMetadata("all.kt")
|
||||
public void testAll() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/defaultParameterValues/defaultWithDefaultParameter/all.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAllFilesPresentInDefaultWithDefaultParameter() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/inlineClasses/defaultParameterValues/defaultWithDefaultParameter"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("all-compatibility.kt")
|
||||
public void testAll_compatibility() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/defaultParameterValues/defaultWithDefaultParameter/all-compatibility.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("compatibility.kt")
|
||||
public void testCompatibility() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/defaultParameterValues/defaultWithDefaultParameter/compatibility.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("default.kt")
|
||||
public void testDefault() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/defaultParameterValues/defaultWithDefaultParameter/default.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/codegen/box/inlineClasses/defaultParameterValues/overrideFunctionWithDefaultParameter")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
|
||||
Reference in New Issue
Block a user