diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/StackValue.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/StackValue.java index 4293155c538..36b6ad8df57 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/StackValue.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/StackValue.java @@ -36,12 +36,14 @@ import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodParameterSignature import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue; import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.kotlin.types.SimpleType; +import org.jetbrains.kotlin.types.TypeUtils; import org.jetbrains.org.objectweb.asm.Label; import org.jetbrains.org.objectweb.asm.Opcodes; import org.jetbrains.org.objectweb.asm.Type; import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter; import java.util.List; +import java.util.function.Consumer; import static org.jetbrains.kotlin.codegen.AsmUtil.*; import static org.jetbrains.kotlin.resolve.jvm.AsmTypes.*; @@ -402,6 +404,21 @@ public abstract class StackValue { Type boxedType = KotlinTypeMapper.mapInlineClassTypeAsDeclaration(kotlinType); Type owner = KotlinTypeMapper.mapToErasedInlineClassType(kotlinType); Type underlyingType = KotlinTypeMapper.mapUnderlyingTypeOfInlineClassType(kotlinType); + + if (TypeUtils.isNullableType(kotlinType) && !isPrimitive(underlyingType)) { + boxOrUnboxWithNullCheck(v, vv -> invokeBoxMethod(vv, boxedType, owner, underlyingType)); + } + else { + invokeBoxMethod(v, boxedType, owner, underlyingType); + } + } + + private static void invokeBoxMethod( + @NotNull InstructionAdapter v, + Type boxedType, + Type owner, + Type underlyingType + ) { v.invokestatic( owner.getInternalName(), InlineClassDescriptorResolver.BOX_METHOD_NAME.asString(), @@ -416,6 +433,16 @@ public abstract class StackValue { coerce(type, owner, v); Type resultType = KotlinTypeMapper.mapUnderlyingTypeOfInlineClassType(targetInlineClassType); + + if (TypeUtils.isNullableType(targetInlineClassType) && !isPrimitive(type)) { + boxOrUnboxWithNullCheck(v, vv -> invokeUnboxMethod(vv, owner, resultType)); + } + else { + invokeUnboxMethod(v, owner, resultType); + } + } + + private static void invokeUnboxMethod(@NotNull InstructionAdapter v, Type owner, Type resultType) { v.invokevirtual( owner.getInternalName(), InlineClassDescriptorResolver.UNBOX_METHOD_NAME.asString(), @@ -424,6 +451,23 @@ public abstract class StackValue { ); } + private static void boxOrUnboxWithNullCheck(@NotNull InstructionAdapter v, @NotNull Consumer body) { + Label lNull = new Label(); + Label lDone = new Label(); + // NB The following piece of code looks sub-optimal (we have a 'null' value on stack and could just keep it there), + // but it is required, because bytecode verifier doesn't take into account null checks, + // and sees null-checked value on the top of the stack as a value of the source type (e.g., Ljava/lang/String;), + // which is not assignable to the expected type (destination type, e.g., LStr;). + v.dup(); + v.ifnull(lNull); + body.accept(v); + v.goTo(lDone); + v.mark(lNull); + v.pop(); + v.aconst(null); + v.mark(lDone); + } + protected void coerceTo(@NotNull Type toType, @Nullable KotlinType toKotlinType, @NotNull InstructionAdapter v) { coerce(this.type, this.kotlinType, toType, toKotlinType, v); } diff --git a/compiler/testData/codegen/box/inlineClasses/boxNullableValueOfInlineClassWithNonNullUnderlyingType.kt b/compiler/testData/codegen/box/inlineClasses/boxNullableValueOfInlineClassWithNonNullUnderlyingType.kt new file mode 100644 index 00000000000..d7d047b6b75 --- /dev/null +++ b/compiler/testData/codegen/box/inlineClasses/boxNullableValueOfInlineClassWithNonNullUnderlyingType.kt @@ -0,0 +1,42 @@ +// !LANGUAGE: +InlineClasses +// IGNORE_BACKEND: JVM_IR + +class BoxT(val boxed: T) +class BoxAny(val boxed: Any?) +class BoxFoo(val boxed: IFoo?) + +interface IFoo + +inline class Str(val value: String) : IFoo + +inline class Str2(val value: Str): IFoo + +inline class StrArr(val value: Array): IFoo + +fun boxToTypeParameter(x: Str?) = BoxT(x) +fun boxToNullableAny(x: Str?) = BoxAny(x) +fun boxToNullableInterface(x: Str?) = BoxFoo(x) + +fun box2ToTypeParameter(x: Str2?) = BoxT(x) +fun box2ToNullableAny(x: Str2?) = BoxAny(x) +fun box2ToNullableInterface(x: Str2?) = BoxFoo(x) + +fun boxArrToTypeParameter(x: StrArr?) = BoxT(x) +fun boxArrToNullableAny(x: StrArr?) = BoxAny(x) +fun boxArrToNullableInterface(x: StrArr?) = BoxFoo(x) + +fun box(): String { + if (boxToNullableAny(null).boxed != null) throw AssertionError() + if (boxToTypeParameter(null).boxed != null) throw AssertionError() + if (boxToNullableInterface(null).boxed != null) throw AssertionError() + + if (box2ToNullableAny(null).boxed != null) throw AssertionError() + if (box2ToTypeParameter(null).boxed != null) throw AssertionError() + if (box2ToNullableInterface(null).boxed != null) throw AssertionError() + + if (boxArrToNullableAny(null).boxed != null) throw AssertionError() + if (boxArrToTypeParameter(null).boxed != null) throw AssertionError() + if (boxArrToNullableInterface(null).boxed != null) throw AssertionError() + + return "OK" +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/inlineClasses/boxNullableValueOfInlineClassWithPrimitiveUnderlyingType.kt b/compiler/testData/codegen/box/inlineClasses/boxNullableValueOfInlineClassWithPrimitiveUnderlyingType.kt new file mode 100644 index 00000000000..daa9c940afa --- /dev/null +++ b/compiler/testData/codegen/box/inlineClasses/boxNullableValueOfInlineClassWithPrimitiveUnderlyingType.kt @@ -0,0 +1,22 @@ +// !LANGUAGE: +InlineClasses +// IGNORE_BACKEND: JVM_IR + +class BoxT(val boxed: T) +class BoxAny(val boxed: Any?) +class BoxFoo(val boxed: IFoo?) + +interface IFoo + +inline class I32(val value: Int): IFoo + +fun boxToTypeParameter(x: I32?) = BoxT(x) +fun boxToNullableAny(x: I32?) = BoxAny(x) +fun boxToNullableInterface(x: I32?) = BoxFoo(x) + +fun box(): String { + if (boxToNullableAny(null).boxed != null) throw AssertionError() + if (boxToTypeParameter(null).boxed != null) throw AssertionError() + if (boxToNullableInterface(null).boxed != null) throw AssertionError() + + return "OK" +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/inlineClasses/equalityForBoxesOfNullableValuesOfInlineClass.kt b/compiler/testData/codegen/box/inlineClasses/equalityForBoxesOfNullableValuesOfInlineClass.kt new file mode 100644 index 00000000000..4783543722e --- /dev/null +++ b/compiler/testData/codegen/box/inlineClasses/equalityForBoxesOfNullableValuesOfInlineClass.kt @@ -0,0 +1,46 @@ +// !LANGUAGE: +InlineClasses +// WITH_RUNTIME +// IGNORE_BACKEND: JVM_IR, JS_IR + +inline class X(val x: String) +inline class Y(val y: Number) + +inline class NX(val x: String?) +inline class NY(val y: Number?) + +fun testNotNull(x: X?, y: Y?) { + val xs = listOf(x) + val ys = listOf(y) + if (!xs.contains(y)) throw AssertionError() + if (xs[0] != ys[0]) throw AssertionError() + if (xs[0] !== ys[0]) throw AssertionError() +} + +fun testNullable(x: NX?, y: NY?) { + val xs = listOf(x) + val ys = listOf(y) + if (xs.contains(y)) throw AssertionError() + if (xs[0] == ys[0]) throw AssertionError() + if (xs[0] === ys[0]) throw AssertionError() +} + +fun testNullsAsNullable(x: NX?, y: NY?) { + val xs = listOf(x) + val ys = listOf(y) + if (!xs.contains(y)) throw AssertionError() + if (xs[0] != ys[0]) throw AssertionError() + if (xs[0] !== ys[0]) throw AssertionError() +} + + +fun box(): String { + testNotNull(null, null) + + testNullable(NX(null), NY(null)) + testNullable(NX(null), null) + testNullable(null, NY(null)) + + testNullsAsNullable(null, null) + + return "OK" +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/inlineClasses/nullableEqeqNonNull.kt b/compiler/testData/codegen/box/inlineClasses/nullableEqeqNonNull.kt index 6379806f839..e743830dc1c 100644 --- a/compiler/testData/codegen/box/inlineClasses/nullableEqeqNonNull.kt +++ b/compiler/testData/codegen/box/inlineClasses/nullableEqeqNonNull.kt @@ -1,5 +1,5 @@ // !LANGUAGE: +InlineClasses -// IGNORE_BACKEND: JVM_IR, JS_IR, JS +// IGNORE_BACKEND: JVM_IR, JS inline class Z(val value: Int) diff --git a/compiler/testData/codegen/box/inlineClasses/unboxNullableValueOfInlineClassWithNonNullUnderlyingType.kt b/compiler/testData/codegen/box/inlineClasses/unboxNullableValueOfInlineClassWithNonNullUnderlyingType.kt new file mode 100644 index 00000000000..83276385ed4 --- /dev/null +++ b/compiler/testData/codegen/box/inlineClasses/unboxNullableValueOfInlineClassWithNonNullUnderlyingType.kt @@ -0,0 +1,54 @@ +// !LANGUAGE: +InlineClasses +// IGNORE_BACKEND: JVM_IR + +class BoxT(val boxed: T) +class BoxAny(val boxed: Any?) +class BoxFoo(val boxed: IFoo?) + +interface IFoo + +inline class Str(val value: String) : IFoo + +inline class Str2(val value: Str): IFoo + +inline class StrArr(val value: Array): IFoo + +fun boxToTypeParameter(x: Str?) = BoxT(x) +fun boxToNullableAny(x: Str?) = BoxAny(x) +fun boxToNullableInterface(x: Str?) = BoxFoo(x) + +fun box2ToTypeParameter(x: Str2?) = BoxT(x) +fun box2ToNullableAny(x: Str2?) = BoxAny(x) +fun box2ToNullableInterface(x: Str2?) = BoxFoo(x) + +fun boxArrToTypeParameter(x: StrArr?) = BoxT(x) +fun boxArrToNullableAny(x: StrArr?) = BoxAny(x) +fun boxArrToNullableInterface(x: StrArr?) = BoxFoo(x) + +fun useNullableStr(x: Str?) { + if (x != null) throw AssertionError() +} + +fun useNullableStr2(x: Str2?) { + if (x != null) throw AssertionError() +} + +fun useNullableStrArr(x: StrArr?) { + if (x != null) throw AssertionError() +} + +fun box(): String { + useNullableStr(boxToTypeParameter(null).boxed) + useNullableStr(boxToNullableAny(null).boxed as Str?) + useNullableStr(boxToNullableInterface(null).boxed as Str?) + + useNullableStr2(box2ToTypeParameter(null).boxed) + useNullableStr2(box2ToNullableAny(null).boxed as Str2?) + useNullableStr2(box2ToNullableInterface(null).boxed as Str2?) + + useNullableStrArr(boxArrToTypeParameter(null).boxed) + useNullableStrArr(boxArrToNullableAny(null).boxed as StrArr?) + useNullableStrArr(boxArrToNullableInterface(null).boxed as StrArr?) + + return "OK" +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/inlineClasses/unboxNullableValueOfInlineClassWithPrimitiveUnderlyingType.kt b/compiler/testData/codegen/box/inlineClasses/unboxNullableValueOfInlineClassWithPrimitiveUnderlyingType.kt new file mode 100644 index 00000000000..8f4adc049e0 --- /dev/null +++ b/compiler/testData/codegen/box/inlineClasses/unboxNullableValueOfInlineClassWithPrimitiveUnderlyingType.kt @@ -0,0 +1,26 @@ +// !LANGUAGE: +InlineClasses +// IGNORE_BACKEND: JVM_IR + +class BoxT(val boxed: T) +class BoxAny(val boxed: Any?) +class BoxFoo(val boxed: IFoo?) + +interface IFoo + +inline class I32(val value: Int) : IFoo + +fun boxToTypeParameter(x: I32?) = BoxT(x) +fun boxToNullableAny(x: I32?) = BoxAny(x) +fun boxToNullableInterface(x: I32?) = BoxFoo(x) + +fun useNullableI32(x: I32?) { + if (x != null) throw AssertionError() +} + +fun box(): String { + useNullableI32(boxToTypeParameter(null).boxed) + useNullableI32(boxToNullableAny(null).boxed as I32?) + useNullableI32(boxToNullableInterface(null).boxed as I32?) + + return "OK" +} \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java index ff53bbd7ed5..5a856e00134 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java @@ -11333,6 +11333,16 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/inlineClasses"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true); } + @TestMetadata("boxNullableValueOfInlineClassWithNonNullUnderlyingType.kt") + public void testBoxNullableValueOfInlineClassWithNonNullUnderlyingType() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/boxNullableValueOfInlineClassWithNonNullUnderlyingType.kt"); + } + + @TestMetadata("boxNullableValueOfInlineClassWithPrimitiveUnderlyingType.kt") + public void testBoxNullableValueOfInlineClassWithPrimitiveUnderlyingType() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/boxNullableValueOfInlineClassWithPrimitiveUnderlyingType.kt"); + } + @TestMetadata("boxUnboxInlineClassesWithOperatorsGetSet.kt") public void testBoxUnboxInlineClassesWithOperatorsGetSet() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/boxUnboxInlineClassesWithOperatorsGetSet.kt"); @@ -11468,6 +11478,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/inlineClasses/emptyConstructorForInlineClass.kt"); } + @TestMetadata("equalityForBoxesOfNullableValuesOfInlineClass.kt") + public void testEqualityForBoxesOfNullableValuesOfInlineClass() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/equalityForBoxesOfNullableValuesOfInlineClass.kt"); + } + @TestMetadata("inlineClassAsLastExpressionInInLambda.kt") public void testInlineClassAsLastExpressionInInLambda() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/inlineClassAsLastExpressionInInLambda.kt"); @@ -11573,6 +11588,16 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/inlineClasses/UIntArraySortExample.kt"); } + @TestMetadata("unboxNullableValueOfInlineClassWithNonNullUnderlyingType.kt") + public void testUnboxNullableValueOfInlineClassWithNonNullUnderlyingType() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/unboxNullableValueOfInlineClassWithNonNullUnderlyingType.kt"); + } + + @TestMetadata("unboxNullableValueOfInlineClassWithPrimitiveUnderlyingType.kt") + public void testUnboxNullableValueOfInlineClassWithPrimitiveUnderlyingType() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/unboxNullableValueOfInlineClassWithPrimitiveUnderlyingType.kt"); + } + @TestMetadata("unboxReceiverOnCallingMethodFromInlineClass.kt") public void testUnboxReceiverOnCallingMethodFromInlineClass() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/unboxReceiverOnCallingMethodFromInlineClass.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 504847aa476..9c83dcfff9d 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -11333,6 +11333,16 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/inlineClasses"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true); } + @TestMetadata("boxNullableValueOfInlineClassWithNonNullUnderlyingType.kt") + public void testBoxNullableValueOfInlineClassWithNonNullUnderlyingType() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/boxNullableValueOfInlineClassWithNonNullUnderlyingType.kt"); + } + + @TestMetadata("boxNullableValueOfInlineClassWithPrimitiveUnderlyingType.kt") + public void testBoxNullableValueOfInlineClassWithPrimitiveUnderlyingType() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/boxNullableValueOfInlineClassWithPrimitiveUnderlyingType.kt"); + } + @TestMetadata("boxUnboxInlineClassesWithOperatorsGetSet.kt") public void testBoxUnboxInlineClassesWithOperatorsGetSet() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/boxUnboxInlineClassesWithOperatorsGetSet.kt"); @@ -11468,6 +11478,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/inlineClasses/emptyConstructorForInlineClass.kt"); } + @TestMetadata("equalityForBoxesOfNullableValuesOfInlineClass.kt") + public void testEqualityForBoxesOfNullableValuesOfInlineClass() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/equalityForBoxesOfNullableValuesOfInlineClass.kt"); + } + @TestMetadata("inlineClassAsLastExpressionInInLambda.kt") public void testInlineClassAsLastExpressionInInLambda() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/inlineClassAsLastExpressionInInLambda.kt"); @@ -11573,6 +11588,16 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/inlineClasses/UIntArraySortExample.kt"); } + @TestMetadata("unboxNullableValueOfInlineClassWithNonNullUnderlyingType.kt") + public void testUnboxNullableValueOfInlineClassWithNonNullUnderlyingType() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/unboxNullableValueOfInlineClassWithNonNullUnderlyingType.kt"); + } + + @TestMetadata("unboxNullableValueOfInlineClassWithPrimitiveUnderlyingType.kt") + public void testUnboxNullableValueOfInlineClassWithPrimitiveUnderlyingType() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/unboxNullableValueOfInlineClassWithPrimitiveUnderlyingType.kt"); + } + @TestMetadata("unboxReceiverOnCallingMethodFromInlineClass.kt") public void testUnboxReceiverOnCallingMethodFromInlineClass() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/unboxReceiverOnCallingMethodFromInlineClass.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java index 7ee7005e0a2..19214ea88e7 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java @@ -11333,6 +11333,16 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/inlineClasses"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM_IR, true); } + @TestMetadata("boxNullableValueOfInlineClassWithNonNullUnderlyingType.kt") + public void testBoxNullableValueOfInlineClassWithNonNullUnderlyingType() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/boxNullableValueOfInlineClassWithNonNullUnderlyingType.kt"); + } + + @TestMetadata("boxNullableValueOfInlineClassWithPrimitiveUnderlyingType.kt") + public void testBoxNullableValueOfInlineClassWithPrimitiveUnderlyingType() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/boxNullableValueOfInlineClassWithPrimitiveUnderlyingType.kt"); + } + @TestMetadata("boxUnboxInlineClassesWithOperatorsGetSet.kt") public void testBoxUnboxInlineClassesWithOperatorsGetSet() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/boxUnboxInlineClassesWithOperatorsGetSet.kt"); @@ -11468,6 +11478,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/inlineClasses/emptyConstructorForInlineClass.kt"); } + @TestMetadata("equalityForBoxesOfNullableValuesOfInlineClass.kt") + public void testEqualityForBoxesOfNullableValuesOfInlineClass() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/equalityForBoxesOfNullableValuesOfInlineClass.kt"); + } + @TestMetadata("inlineClassAsLastExpressionInInLambda.kt") public void testInlineClassAsLastExpressionInInLambda() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/inlineClassAsLastExpressionInInLambda.kt"); @@ -11573,6 +11588,16 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/inlineClasses/UIntArraySortExample.kt"); } + @TestMetadata("unboxNullableValueOfInlineClassWithNonNullUnderlyingType.kt") + public void testUnboxNullableValueOfInlineClassWithNonNullUnderlyingType() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/unboxNullableValueOfInlineClassWithNonNullUnderlyingType.kt"); + } + + @TestMetadata("unboxNullableValueOfInlineClassWithPrimitiveUnderlyingType.kt") + public void testUnboxNullableValueOfInlineClassWithPrimitiveUnderlyingType() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/unboxNullableValueOfInlineClassWithPrimitiveUnderlyingType.kt"); + } + @TestMetadata("unboxReceiverOnCallingMethodFromInlineClass.kt") public void testUnboxReceiverOnCallingMethodFromInlineClass() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/unboxReceiverOnCallingMethodFromInlineClass.kt"); diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/IrJsCodegenBoxTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/IrJsCodegenBoxTestGenerated.java index 923d9b25c57..babb2dc0ae8 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/IrJsCodegenBoxTestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/IrJsCodegenBoxTestGenerated.java @@ -9918,6 +9918,16 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/inlineClasses"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JS_IR, true); } + @TestMetadata("boxNullableValueOfInlineClassWithNonNullUnderlyingType.kt") + public void testBoxNullableValueOfInlineClassWithNonNullUnderlyingType() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/boxNullableValueOfInlineClassWithNonNullUnderlyingType.kt"); + } + + @TestMetadata("boxNullableValueOfInlineClassWithPrimitiveUnderlyingType.kt") + public void testBoxNullableValueOfInlineClassWithPrimitiveUnderlyingType() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/boxNullableValueOfInlineClassWithPrimitiveUnderlyingType.kt"); + } + @TestMetadata("boxUnboxInlineClassesWithOperatorsGetSet.kt") public void testBoxUnboxInlineClassesWithOperatorsGetSet() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/boxUnboxInlineClassesWithOperatorsGetSet.kt"); @@ -10048,6 +10058,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { runTest("compiler/testData/codegen/box/inlineClasses/emptyConstructorForInlineClass.kt"); } + @TestMetadata("equalityForBoxesOfNullableValuesOfInlineClass.kt") + public void testEqualityForBoxesOfNullableValuesOfInlineClass() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/equalityForBoxesOfNullableValuesOfInlineClass.kt"); + } + @TestMetadata("inlineClassAsLastExpressionInInLambda.kt") public void testInlineClassAsLastExpressionInInLambda() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/inlineClassAsLastExpressionInInLambda.kt"); @@ -10148,6 +10163,16 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { runTest("compiler/testData/codegen/box/inlineClasses/UIntArraySortExample.kt"); } + @TestMetadata("unboxNullableValueOfInlineClassWithNonNullUnderlyingType.kt") + public void testUnboxNullableValueOfInlineClassWithNonNullUnderlyingType() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/unboxNullableValueOfInlineClassWithNonNullUnderlyingType.kt"); + } + + @TestMetadata("unboxNullableValueOfInlineClassWithPrimitiveUnderlyingType.kt") + public void testUnboxNullableValueOfInlineClassWithPrimitiveUnderlyingType() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/unboxNullableValueOfInlineClassWithPrimitiveUnderlyingType.kt"); + } + @TestMetadata("unboxReceiverOnCallingMethodFromInlineClass.kt") public void testUnboxReceiverOnCallingMethodFromInlineClass() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/unboxReceiverOnCallingMethodFromInlineClass.kt"); diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java index 35df04d9c6c..5406d003227 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java @@ -10968,6 +10968,16 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/inlineClasses"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JS, true); } + @TestMetadata("boxNullableValueOfInlineClassWithNonNullUnderlyingType.kt") + public void testBoxNullableValueOfInlineClassWithNonNullUnderlyingType() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/boxNullableValueOfInlineClassWithNonNullUnderlyingType.kt"); + } + + @TestMetadata("boxNullableValueOfInlineClassWithPrimitiveUnderlyingType.kt") + public void testBoxNullableValueOfInlineClassWithPrimitiveUnderlyingType() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/boxNullableValueOfInlineClassWithPrimitiveUnderlyingType.kt"); + } + @TestMetadata("boxUnboxInlineClassesWithOperatorsGetSet.kt") public void testBoxUnboxInlineClassesWithOperatorsGetSet() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/boxUnboxInlineClassesWithOperatorsGetSet.kt"); @@ -11098,6 +11108,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { runTest("compiler/testData/codegen/box/inlineClasses/emptyConstructorForInlineClass.kt"); } + @TestMetadata("equalityForBoxesOfNullableValuesOfInlineClass.kt") + public void testEqualityForBoxesOfNullableValuesOfInlineClass() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/equalityForBoxesOfNullableValuesOfInlineClass.kt"); + } + @TestMetadata("inlineClassAsLastExpressionInInLambda.kt") public void testInlineClassAsLastExpressionInInLambda() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/inlineClassAsLastExpressionInInLambda.kt"); @@ -11198,6 +11213,16 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { runTest("compiler/testData/codegen/box/inlineClasses/UIntArraySortExample.kt"); } + @TestMetadata("unboxNullableValueOfInlineClassWithNonNullUnderlyingType.kt") + public void testUnboxNullableValueOfInlineClassWithNonNullUnderlyingType() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/unboxNullableValueOfInlineClassWithNonNullUnderlyingType.kt"); + } + + @TestMetadata("unboxNullableValueOfInlineClassWithPrimitiveUnderlyingType.kt") + public void testUnboxNullableValueOfInlineClassWithPrimitiveUnderlyingType() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/unboxNullableValueOfInlineClassWithPrimitiveUnderlyingType.kt"); + } + @TestMetadata("unboxReceiverOnCallingMethodFromInlineClass.kt") public void testUnboxReceiverOnCallingMethodFromInlineClass() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/unboxReceiverOnCallingMethodFromInlineClass.kt");