Make generation of assertions for platform types aware of kotlin types
#KT-26859 Fixed
This commit is contained in:
@@ -910,19 +910,20 @@ public class AsmUtil {
|
||||
if (state.isCallAssertionsDisabled()) return stackValue;
|
||||
if (runtimeAssertionInfo == null || !runtimeAssertionInfo.getNeedNotNullAssertion()) return stackValue;
|
||||
|
||||
return new StackValue(stackValue.type) {
|
||||
return new StackValue(stackValue.type, stackValue.kotlinType) {
|
||||
|
||||
@Override
|
||||
public void putSelector(@NotNull Type type, @Nullable KotlinType kotlinType, @NotNull InstructionAdapter v) {
|
||||
Type innerType = stackValue.type;
|
||||
stackValue.put(innerType, v);
|
||||
KotlinType innerKotlinType = stackValue.kotlinType;
|
||||
stackValue.put(innerType, innerKotlinType, v);
|
||||
if (innerType.getSort() == Type.OBJECT || innerType.getSort() == Type.ARRAY) {
|
||||
v.dup();
|
||||
v.visitLdcInsn(runtimeAssertionInfo.getMessage());
|
||||
v.invokestatic(IntrinsicMethods.INTRINSICS_CLASS_NAME, "checkExpressionValueIsNotNull",
|
||||
"(Ljava/lang/Object;Ljava/lang/String;)V", false);
|
||||
}
|
||||
StackValue.coerce(innerType, type, v);
|
||||
StackValue.coerce(innerType, innerKotlinType, type, kotlinType, v);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
// WITH_RUNTIME
|
||||
// IGNORE_BACKEND: JVM_IR, JS_IR, NATIVE
|
||||
|
||||
inline class SnekDirection(val direction: Int) {
|
||||
companion object {
|
||||
val Up = SnekDirection(0)
|
||||
}
|
||||
}
|
||||
|
||||
fun testUnbox() : SnekDirection {
|
||||
val list = arrayListOf(SnekDirection.Up)
|
||||
return list[0]
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val a = testUnbox()
|
||||
return if (a.direction == 0) "OK" else "Fail"
|
||||
}
|
||||
+5
@@ -11844,6 +11844,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/unboxReceiverOnCallingMethodFromInlineClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("unboxValueFromPlatformType.kt")
|
||||
public void testUnboxValueFromPlatformType() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/unboxValueFromPlatformType.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("useInlineClassesInsideElvisOperator.kt")
|
||||
public void testUseInlineClassesInsideElvisOperator() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/useInlineClassesInsideElvisOperator.kt");
|
||||
|
||||
+5
@@ -11844,6 +11844,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/unboxReceiverOnCallingMethodFromInlineClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("unboxValueFromPlatformType.kt")
|
||||
public void testUnboxValueFromPlatformType() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/unboxValueFromPlatformType.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("useInlineClassesInsideElvisOperator.kt")
|
||||
public void testUseInlineClassesInsideElvisOperator() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/useInlineClassesInsideElvisOperator.kt");
|
||||
|
||||
+5
@@ -11849,6 +11849,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/unboxReceiverOnCallingMethodFromInlineClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("unboxValueFromPlatformType.kt")
|
||||
public void testUnboxValueFromPlatformType() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/unboxValueFromPlatformType.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("useInlineClassesInsideElvisOperator.kt")
|
||||
public void testUseInlineClassesInsideElvisOperator() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/useInlineClassesInsideElvisOperator.kt");
|
||||
|
||||
+5
@@ -10379,6 +10379,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/unboxReceiverOnCallingMethodFromInlineClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("unboxValueFromPlatformType.kt")
|
||||
public void testUnboxValueFromPlatformType() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/unboxValueFromPlatformType.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("useInlineClassesInsideElvisOperator.kt")
|
||||
public void testUseInlineClassesInsideElvisOperator() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/useInlineClassesInsideElvisOperator.kt");
|
||||
|
||||
+5
@@ -11444,6 +11444,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/unboxReceiverOnCallingMethodFromInlineClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("unboxValueFromPlatformType.kt")
|
||||
public void testUnboxValueFromPlatformType() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/unboxValueFromPlatformType.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("useInlineClassesInsideElvisOperator.kt")
|
||||
public void testUseInlineClassesInsideElvisOperator() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/useInlineClassesInsideElvisOperator.kt");
|
||||
|
||||
Reference in New Issue
Block a user