Fix generation of elvis with null constant for inline classes
This commit is contained in:
@@ -356,11 +356,16 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
return (ScriptContext) context;
|
||||
}
|
||||
|
||||
public StackValue genLazy(KtElement expr, Type type) {
|
||||
private StackValue genLazy(KtElement expr, Type type) {
|
||||
StackValue value = gen(expr);
|
||||
return StackValue.coercion(value, type, null);
|
||||
}
|
||||
|
||||
private StackValue genLazy(KtElement expr, Type type, KotlinType kotlinType) {
|
||||
StackValue value = gen(expr);
|
||||
return StackValue.coercion(value, type, kotlinType);
|
||||
}
|
||||
|
||||
private StackValue genStatement(KtElement statement) {
|
||||
return genQualified(StackValue.none(), statement, statementVisitor);
|
||||
}
|
||||
@@ -3008,7 +3013,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
return StackValue.coercion(generateSafeQualifiedExpression((KtSafeQualifiedExpression) expression, ifnull), type, kotlinType);
|
||||
}
|
||||
else {
|
||||
return genLazy(expression, type);
|
||||
return genLazy(expression, type, kotlinType);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// !LANGUAGE: +InlineClasses
|
||||
|
||||
inline class UInt(private val data: Int) {
|
||||
fun result(): String = if (data == 1) "OK" else "fail"
|
||||
}
|
||||
|
||||
fun f(): UInt {
|
||||
val unull = UInt(1) ?: null
|
||||
return nonNull(unull)
|
||||
}
|
||||
|
||||
fun nonNull(u: UInt?) = u!!
|
||||
|
||||
fun box(): String {
|
||||
return f().result()
|
||||
}
|
||||
Vendored
+13
@@ -0,0 +1,13 @@
|
||||
// !LANGUAGE: +InlineClasses
|
||||
|
||||
inline class UInt(private val data: Int)
|
||||
|
||||
fun f() {
|
||||
val unull = UInt(1) ?: null
|
||||
}
|
||||
|
||||
// 1 INVOKESTATIC UInt\$Erased.box
|
||||
// 0 INVOKEVIRTUAL UInt.unbox
|
||||
|
||||
// 0 valueOf
|
||||
// 0 intValue
|
||||
Generated
+5
@@ -11073,6 +11073,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/createInlineClassInArgumentPosition.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("elvisWithInlineClassAndNullConstant.kt")
|
||||
public void testElvisWithInlineClassAndNullConstant() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/elvisWithInlineClassAndNullConstant.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("emptyConstructorForInlineClass.kt")
|
||||
public void testEmptyConstructorForInlineClass() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/emptyConstructorForInlineClass.kt");
|
||||
|
||||
+5
@@ -11073,6 +11073,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/createInlineClassInArgumentPosition.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("elvisWithInlineClassAndNullConstant.kt")
|
||||
public void testElvisWithInlineClassAndNullConstant() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/elvisWithInlineClassAndNullConstant.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("emptyConstructorForInlineClass.kt")
|
||||
public void testEmptyConstructorForInlineClass() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/emptyConstructorForInlineClass.kt");
|
||||
|
||||
@@ -1983,6 +1983,11 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest {
|
||||
runTest("compiler/testData/codegen/bytecodeText/inlineClasses/assertionsForParametersOfInlineClassTypes.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("boxInlineClassInsideElvisWithNullConstant.kt")
|
||||
public void testBoxInlineClassInsideElvisWithNullConstant() throws Exception {
|
||||
runTest("compiler/testData/codegen/bytecodeText/inlineClasses/boxInlineClassInsideElvisWithNullConstant.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("boxInlineClassesOnPassingToVarargs.kt")
|
||||
public void testBoxInlineClassesOnPassingToVarargs() throws Exception {
|
||||
runTest("compiler/testData/codegen/bytecodeText/inlineClasses/boxInlineClassesOnPassingToVarargs.kt");
|
||||
|
||||
+5
@@ -11073,6 +11073,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/createInlineClassInArgumentPosition.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("elvisWithInlineClassAndNullConstant.kt")
|
||||
public void testElvisWithInlineClassAndNullConstant() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/elvisWithInlineClassAndNullConstant.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("emptyConstructorForInlineClass.kt")
|
||||
public void testEmptyConstructorForInlineClass() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/emptyConstructorForInlineClass.kt");
|
||||
|
||||
+5
@@ -9630,6 +9630,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/createInlineClassInArgumentPosition.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("elvisWithInlineClassAndNullConstant.kt")
|
||||
public void testElvisWithInlineClassAndNullConstant() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/elvisWithInlineClassAndNullConstant.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("emptyConstructorForInlineClass.kt")
|
||||
public void testEmptyConstructorForInlineClass() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/emptyConstructorForInlineClass.kt");
|
||||
|
||||
Reference in New Issue
Block a user