Fix inline classes coercion in 'if' expression
#KT-27132
This commit is contained in:
@@ -513,7 +513,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
}
|
||||
}
|
||||
|
||||
return StackValue.operation(asmType, v -> {
|
||||
return StackValue.operation(asmType, kotlinType, v -> {
|
||||
Label elseLabel = new Label();
|
||||
BranchedValue.Companion.condJump(condition, elseLabel, true, v);
|
||||
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
// !LANGUAGE: +InlineClasses
|
||||
// IGNORE_BACKEND: JVM_IR, JS_IR
|
||||
// WITH_RUNTIME
|
||||
|
||||
inline class Ucn(private val i: UInt)
|
||||
|
||||
interface Input<T> {
|
||||
fun foo(n: Int = 0): T
|
||||
}
|
||||
|
||||
fun Char.toUInt() = toInt().toUInt()
|
||||
|
||||
class Kx(val x: UInt) : Input<Ucn> {
|
||||
override fun foo(n: Int): Ucn =
|
||||
if (n < 0) Ucn(0u) else Ucn(x)
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val p = Kx(42u).foo()
|
||||
if (p.toString() != "Ucn(i=42)") throw AssertionError()
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+5
@@ -11859,6 +11859,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/kt27096_reference.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt27132.kt")
|
||||
public void testKt27132() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/kt27132.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt27140.kt")
|
||||
public void testKt27140() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/kt27140.kt");
|
||||
|
||||
+5
@@ -11859,6 +11859,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/kt27096_reference.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt27132.kt")
|
||||
public void testKt27132() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/kt27132.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt27140.kt")
|
||||
public void testKt27140() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/kt27140.kt");
|
||||
|
||||
+5
@@ -11864,6 +11864,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/kt27096_reference.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt27132.kt")
|
||||
public void testKt27132() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/kt27132.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt27140.kt")
|
||||
public void testKt27140() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/kt27140.kt");
|
||||
|
||||
+5
@@ -10399,6 +10399,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/kt27096_reference.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt27132.kt")
|
||||
public void testKt27132() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/kt27132.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt27140.kt")
|
||||
public void testKt27140() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/kt27140.kt");
|
||||
|
||||
+5
@@ -11444,6 +11444,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/kt27096_reference.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt27132.kt")
|
||||
public void testKt27132() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/kt27132.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt27140.kt")
|
||||
public void testKt27140() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/kt27140.kt");
|
||||
|
||||
Reference in New Issue
Block a user