Propagate KotlinType into if expression codegen for inline classes
This commit is contained in:
@@ -491,12 +491,12 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
|||||||
|
|
||||||
Label end = new Label();
|
Label end = new Label();
|
||||||
|
|
||||||
gen(thenExpression, asmType);
|
gen(thenExpression, asmType, kotlinType);
|
||||||
|
|
||||||
v.goTo(end);
|
v.goTo(end);
|
||||||
v.mark(elseLabel);
|
v.mark(elseLabel);
|
||||||
|
|
||||||
gen(elseExpression, asmType);
|
gen(elseExpression, asmType, kotlinType);
|
||||||
|
|
||||||
markLineNumber(expression, isStatement);
|
markLineNumber(expression, isStatement);
|
||||||
v.mark(end);
|
v.mark(end);
|
||||||
|
|||||||
+19
@@ -0,0 +1,19 @@
|
|||||||
|
// !LANGUAGE: +InlineClasses
|
||||||
|
|
||||||
|
interface Base {
|
||||||
|
fun result(): Int
|
||||||
|
}
|
||||||
|
|
||||||
|
inline class Inlined(val x: Int) : Base {
|
||||||
|
override fun result(): Int = x
|
||||||
|
}
|
||||||
|
|
||||||
|
fun foo(b: Boolean): Base {
|
||||||
|
return if (b) Inlined(0) else Inlined(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
if (foo(true).result() != 0) return "Fail 1"
|
||||||
|
if (foo(false).result() != 1) return "Fail 2"
|
||||||
|
return "OK"
|
||||||
|
}
|
||||||
Generated
+5
@@ -11244,6 +11244,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
|||||||
runTest("compiler/testData/codegen/box/inlineClasses/computablePropertyInsideInlineClass.kt");
|
runTest("compiler/testData/codegen/box/inlineClasses/computablePropertyInsideInlineClass.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("correctBoxingForBranchExpressions.kt")
|
||||||
|
public void testCorrectBoxingForBranchExpressions() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/inlineClasses/correctBoxingForBranchExpressions.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("createInlineClassInArgumentPosition.kt")
|
@TestMetadata("createInlineClassInArgumentPosition.kt")
|
||||||
public void testCreateInlineClassInArgumentPosition() throws Exception {
|
public void testCreateInlineClassInArgumentPosition() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/inlineClasses/createInlineClassInArgumentPosition.kt");
|
runTest("compiler/testData/codegen/box/inlineClasses/createInlineClassInArgumentPosition.kt");
|
||||||
|
|||||||
+5
@@ -11244,6 +11244,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
|||||||
runTest("compiler/testData/codegen/box/inlineClasses/computablePropertyInsideInlineClass.kt");
|
runTest("compiler/testData/codegen/box/inlineClasses/computablePropertyInsideInlineClass.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("correctBoxingForBranchExpressions.kt")
|
||||||
|
public void testCorrectBoxingForBranchExpressions() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/inlineClasses/correctBoxingForBranchExpressions.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("createInlineClassInArgumentPosition.kt")
|
@TestMetadata("createInlineClassInArgumentPosition.kt")
|
||||||
public void testCreateInlineClassInArgumentPosition() throws Exception {
|
public void testCreateInlineClassInArgumentPosition() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/inlineClasses/createInlineClassInArgumentPosition.kt");
|
runTest("compiler/testData/codegen/box/inlineClasses/createInlineClassInArgumentPosition.kt");
|
||||||
|
|||||||
+5
@@ -11244,6 +11244,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
|||||||
runTest("compiler/testData/codegen/box/inlineClasses/computablePropertyInsideInlineClass.kt");
|
runTest("compiler/testData/codegen/box/inlineClasses/computablePropertyInsideInlineClass.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("correctBoxingForBranchExpressions.kt")
|
||||||
|
public void testCorrectBoxingForBranchExpressions() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/inlineClasses/correctBoxingForBranchExpressions.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("createInlineClassInArgumentPosition.kt")
|
@TestMetadata("createInlineClassInArgumentPosition.kt")
|
||||||
public void testCreateInlineClassInArgumentPosition() throws Exception {
|
public void testCreateInlineClassInArgumentPosition() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/inlineClasses/createInlineClassInArgumentPosition.kt");
|
runTest("compiler/testData/codegen/box/inlineClasses/createInlineClassInArgumentPosition.kt");
|
||||||
|
|||||||
+5
@@ -10904,6 +10904,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
|||||||
runTest("compiler/testData/codegen/box/inlineClasses/computablePropertyInsideInlineClass.kt");
|
runTest("compiler/testData/codegen/box/inlineClasses/computablePropertyInsideInlineClass.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("correctBoxingForBranchExpressions.kt")
|
||||||
|
public void testCorrectBoxingForBranchExpressions() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/inlineClasses/correctBoxingForBranchExpressions.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("createInlineClassInArgumentPosition.kt")
|
@TestMetadata("createInlineClassInArgumentPosition.kt")
|
||||||
public void testCreateInlineClassInArgumentPosition() throws Exception {
|
public void testCreateInlineClassInArgumentPosition() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/inlineClasses/createInlineClassInArgumentPosition.kt");
|
runTest("compiler/testData/codegen/box/inlineClasses/createInlineClassInArgumentPosition.kt");
|
||||||
|
|||||||
+5
@@ -9782,6 +9782,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
|||||||
runTest("compiler/testData/codegen/box/inlineClasses/computablePropertyInsideInlineClass.kt");
|
runTest("compiler/testData/codegen/box/inlineClasses/computablePropertyInsideInlineClass.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("correctBoxingForBranchExpressions.kt")
|
||||||
|
public void testCorrectBoxingForBranchExpressions() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/inlineClasses/correctBoxingForBranchExpressions.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("createInlineClassInArgumentPosition.kt")
|
@TestMetadata("createInlineClassInArgumentPosition.kt")
|
||||||
public void testCreateInlineClassInArgumentPosition() throws Exception {
|
public void testCreateInlineClassInArgumentPosition() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/inlineClasses/createInlineClassInArgumentPosition.kt");
|
runTest("compiler/testData/codegen/box/inlineClasses/createInlineClassInArgumentPosition.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user