Fix inline class coercion in default parameter values
#KT-27358
This commit is contained in:
@@ -1266,7 +1266,8 @@ public class FunctionCodegen {
|
||||
Label loadArg = new Label();
|
||||
iv.ifeq(loadArg);
|
||||
|
||||
StackValue.local(parameterIndex, type).store(loadStrategy.genValue(parameterDescriptor, codegen), iv);
|
||||
StackValue.local(parameterIndex, type, parameterDescriptor.getType())
|
||||
.store(loadStrategy.genValue(parameterDescriptor, codegen), iv);
|
||||
|
||||
iv.mark(loadArg);
|
||||
}
|
||||
|
||||
Vendored
+15
@@ -0,0 +1,15 @@
|
||||
// !LANGUAGE: +InlineClasses
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
|
||||
inline class Z(val z: Int)
|
||||
|
||||
class Test(val z: Z = Z(42)) {
|
||||
fun test() = z.z
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
if (Test().test() != 42) throw AssertionError()
|
||||
if (Test(Z(123)).test() != 123) throw AssertionError()
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Vendored
+24
@@ -0,0 +1,24 @@
|
||||
// !LANGUAGE: +InlineClasses
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
|
||||
inline class Z(val z: Int)
|
||||
|
||||
interface ITest {
|
||||
fun testDefault(z: Z = Z(42)) = z.z
|
||||
|
||||
fun testOverridden(z: Z = Z(42)): Int
|
||||
}
|
||||
|
||||
class Test : ITest {
|
||||
override fun testOverridden(z: Z) = z.z
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
if (Test().testDefault() != 42) throw AssertionError()
|
||||
if (Test().testDefault(Z(123)) != 123) throw AssertionError()
|
||||
|
||||
if (Test().testOverridden() != 42) throw AssertionError()
|
||||
if (Test().testOverridden(Z(123)) != 123) throw AssertionError()
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// !LANGUAGE: +InlineClasses
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
|
||||
inline class Z(val z: Int)
|
||||
|
||||
fun test(z: Z = Z(42)) = z.z
|
||||
|
||||
fun box(): String {
|
||||
if (test() != 42) throw AssertionError()
|
||||
if (test(Z(123)) != 123) throw AssertionError()
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Vendored
+29
@@ -0,0 +1,29 @@
|
||||
// !LANGUAGE: +InlineClasses
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
|
||||
interface IFoo {
|
||||
fun foo(): String
|
||||
}
|
||||
|
||||
inline class Z(val z: Int) : IFoo {
|
||||
override fun foo() = z.toString()
|
||||
}
|
||||
|
||||
fun testNullable(z: Z? = Z(42)) = z!!.z
|
||||
|
||||
fun testAny(z: Any = Z(42)) = (z as Z).z
|
||||
|
||||
fun testInterface(z: IFoo = Z(42)) = z.foo()
|
||||
|
||||
fun box(): String {
|
||||
if (testNullable() != 42) throw AssertionError()
|
||||
if (testNullable(Z(123)) != 123) throw AssertionError()
|
||||
|
||||
if (testAny() != 42) throw AssertionError()
|
||||
if (testAny(Z(123)) != 123) throw AssertionError()
|
||||
|
||||
if (testInterface() != "42") throw AssertionError()
|
||||
if (testInterface(Z(123)) != "123") throw AssertionError()
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+20
@@ -11649,11 +11649,31 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/crossinlineWithInlineClassInParameter.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("defaultConstructorParameterValuesOfInlineClassType.kt")
|
||||
public void testDefaultConstructorParameterValuesOfInlineClassType() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/defaultConstructorParameterValuesOfInlineClassType.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("defaultFunctionsFromAnyForInlineClass.kt")
|
||||
public void testDefaultFunctionsFromAnyForInlineClass() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/defaultFunctionsFromAnyForInlineClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("defaultInterfaceFunParameterValuesOfInlineClassType.kt")
|
||||
public void testDefaultInterfaceFunParameterValuesOfInlineClassType() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/defaultInterfaceFunParameterValuesOfInlineClassType.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("defaultParameterValuesOfInlineClassType.kt")
|
||||
public void testDefaultParameterValuesOfInlineClassType() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/defaultParameterValuesOfInlineClassType.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("defaultParameterValuesOfInlineClassTypeBoxing.kt")
|
||||
public void testDefaultParameterValuesOfInlineClassTypeBoxing() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/defaultParameterValuesOfInlineClassTypeBoxing.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("defaultValueOfInlineClassTypeInInlineFun.kt")
|
||||
public void testDefaultValueOfInlineClassTypeInInlineFun() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/defaultValueOfInlineClassTypeInInlineFun.kt");
|
||||
|
||||
+20
@@ -11649,11 +11649,31 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/crossinlineWithInlineClassInParameter.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("defaultConstructorParameterValuesOfInlineClassType.kt")
|
||||
public void testDefaultConstructorParameterValuesOfInlineClassType() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/defaultConstructorParameterValuesOfInlineClassType.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("defaultFunctionsFromAnyForInlineClass.kt")
|
||||
public void testDefaultFunctionsFromAnyForInlineClass() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/defaultFunctionsFromAnyForInlineClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("defaultInterfaceFunParameterValuesOfInlineClassType.kt")
|
||||
public void testDefaultInterfaceFunParameterValuesOfInlineClassType() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/defaultInterfaceFunParameterValuesOfInlineClassType.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("defaultParameterValuesOfInlineClassType.kt")
|
||||
public void testDefaultParameterValuesOfInlineClassType() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/defaultParameterValuesOfInlineClassType.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("defaultParameterValuesOfInlineClassTypeBoxing.kt")
|
||||
public void testDefaultParameterValuesOfInlineClassTypeBoxing() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/defaultParameterValuesOfInlineClassTypeBoxing.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("defaultValueOfInlineClassTypeInInlineFun.kt")
|
||||
public void testDefaultValueOfInlineClassTypeInInlineFun() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/defaultValueOfInlineClassTypeInInlineFun.kt");
|
||||
|
||||
+20
@@ -11654,11 +11654,31 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/crossinlineWithInlineClassInParameter.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("defaultConstructorParameterValuesOfInlineClassType.kt")
|
||||
public void testDefaultConstructorParameterValuesOfInlineClassType() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/defaultConstructorParameterValuesOfInlineClassType.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("defaultFunctionsFromAnyForInlineClass.kt")
|
||||
public void testDefaultFunctionsFromAnyForInlineClass() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/defaultFunctionsFromAnyForInlineClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("defaultInterfaceFunParameterValuesOfInlineClassType.kt")
|
||||
public void testDefaultInterfaceFunParameterValuesOfInlineClassType() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/defaultInterfaceFunParameterValuesOfInlineClassType.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("defaultParameterValuesOfInlineClassType.kt")
|
||||
public void testDefaultParameterValuesOfInlineClassType() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/defaultParameterValuesOfInlineClassType.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("defaultParameterValuesOfInlineClassTypeBoxing.kt")
|
||||
public void testDefaultParameterValuesOfInlineClassTypeBoxing() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/defaultParameterValuesOfInlineClassTypeBoxing.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("defaultValueOfInlineClassTypeInInlineFun.kt")
|
||||
public void testDefaultValueOfInlineClassTypeInInlineFun() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/defaultValueOfInlineClassTypeInInlineFun.kt");
|
||||
|
||||
+20
@@ -10189,11 +10189,31 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/crossinlineWithInlineClassInParameter.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("defaultConstructorParameterValuesOfInlineClassType.kt")
|
||||
public void testDefaultConstructorParameterValuesOfInlineClassType() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/defaultConstructorParameterValuesOfInlineClassType.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("defaultFunctionsFromAnyForInlineClass.kt")
|
||||
public void testDefaultFunctionsFromAnyForInlineClass() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/defaultFunctionsFromAnyForInlineClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("defaultInterfaceFunParameterValuesOfInlineClassType.kt")
|
||||
public void testDefaultInterfaceFunParameterValuesOfInlineClassType() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/defaultInterfaceFunParameterValuesOfInlineClassType.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("defaultParameterValuesOfInlineClassType.kt")
|
||||
public void testDefaultParameterValuesOfInlineClassType() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/defaultParameterValuesOfInlineClassType.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("defaultParameterValuesOfInlineClassTypeBoxing.kt")
|
||||
public void testDefaultParameterValuesOfInlineClassTypeBoxing() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/defaultParameterValuesOfInlineClassTypeBoxing.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("defaultValueOfInlineClassTypeInInlineFun.kt")
|
||||
public void testDefaultValueOfInlineClassTypeInInlineFun() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/defaultValueOfInlineClassTypeInInlineFun.kt");
|
||||
|
||||
+20
@@ -11234,11 +11234,31 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/crossinlineWithInlineClassInParameter.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("defaultConstructorParameterValuesOfInlineClassType.kt")
|
||||
public void testDefaultConstructorParameterValuesOfInlineClassType() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/defaultConstructorParameterValuesOfInlineClassType.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("defaultFunctionsFromAnyForInlineClass.kt")
|
||||
public void testDefaultFunctionsFromAnyForInlineClass() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/defaultFunctionsFromAnyForInlineClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("defaultInterfaceFunParameterValuesOfInlineClassType.kt")
|
||||
public void testDefaultInterfaceFunParameterValuesOfInlineClassType() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/defaultInterfaceFunParameterValuesOfInlineClassType.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("defaultParameterValuesOfInlineClassType.kt")
|
||||
public void testDefaultParameterValuesOfInlineClassType() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/defaultParameterValuesOfInlineClassType.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("defaultParameterValuesOfInlineClassTypeBoxing.kt")
|
||||
public void testDefaultParameterValuesOfInlineClassTypeBoxing() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/defaultParameterValuesOfInlineClassTypeBoxing.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("defaultValueOfInlineClassTypeInInlineFun.kt")
|
||||
public void testDefaultValueOfInlineClassTypeInInlineFun() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/defaultValueOfInlineClassTypeInInlineFun.kt");
|
||||
|
||||
Reference in New Issue
Block a user