Propagate KotlinType into if expression codegen for inline classes

This commit is contained in:
Mikhail Zarechenskiy
2018-06-19 15:57:24 +03:00
parent c8c943e5fe
commit f326fd66be
7 changed files with 46 additions and 2 deletions
@@ -491,12 +491,12 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
Label end = new Label();
gen(thenExpression, asmType);
gen(thenExpression, asmType, kotlinType);
v.goTo(end);
v.mark(elseLabel);
gen(elseExpression, asmType);
gen(elseExpression, asmType, kotlinType);
markLineNumber(expression, isStatement);
v.mark(end);
@@ -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"
}
@@ -11244,6 +11244,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
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")
public void testCreateInlineClassInArgumentPosition() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/createInlineClassInArgumentPosition.kt");
@@ -11244,6 +11244,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
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")
public void testCreateInlineClassInArgumentPosition() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/createInlineClassInArgumentPosition.kt");
@@ -11244,6 +11244,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
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")
public void testCreateInlineClassInArgumentPosition() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/createInlineClassInArgumentPosition.kt");
@@ -10904,6 +10904,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
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")
public void testCreateInlineClassInArgumentPosition() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/createInlineClassInArgumentPosition.kt");
@@ -9782,6 +9782,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
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")
public void testCreateInlineClassInArgumentPosition() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/createInlineClassInArgumentPosition.kt");