diff --git a/compiler/testData/codegen/box/inlineClasses/kt28879.kt b/compiler/testData/codegen/box/inlineClasses/kt28879.kt new file mode 100644 index 00000000000..3b6fda847de --- /dev/null +++ b/compiler/testData/codegen/box/inlineClasses/kt28879.kt @@ -0,0 +1,19 @@ +// WITH_REFLECT +// TARGET_BACKEND: JVM +// IGNORE_BACKEND: JVM_IR + +import java.util.concurrent.atomic.AtomicReference +import java.util.Arrays + +fun box(): String { + val a0 = AtomicReference(0.toUByte()).get().javaClass + val a1 = AtomicReference(0u).get().javaClass + + val b = Arrays.asList(42u).first().javaClass + + if (a0.toString() != "class kotlin.UByte") return "Fail 1" + if (a1.toString() != "class kotlin.UInt") return "Fail 2" + if (b.toString() != "class kotlin.UInt") return "Fail 3" + + return "OK" +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/inlineClasses/mappingOfBoxedFlexibleInlineClassType.kt b/compiler/testData/codegen/box/inlineClasses/mappingOfBoxedFlexibleInlineClassType.kt new file mode 100644 index 00000000000..92828881fc5 --- /dev/null +++ b/compiler/testData/codegen/box/inlineClasses/mappingOfBoxedFlexibleInlineClassType.kt @@ -0,0 +1,35 @@ +// WITH_RUNTIME +// TARGET_BACKEND: JVM +// IGNORE_BACKEND: JVM_IR + +// FILE: JavaClass.java + +public class JavaClass { + public static T id(T x) { return x; } +} + +// FILE: test.kt + +inline class IcInt(val i: Int) +inline class IcLong(val l: Long) +inline class IcAny(val a: Any?) +inline class IcOverIc(val o: IcInt) + +fun box(): String { + val i = IcInt(1) + val l = IcLong(2) + val a = IcAny("string") + val o = IcOverIc(IcInt(3)) + + val ij = JavaClass.id(i) + val lj = JavaClass.id(l) + val aj = JavaClass.id(a) + val oj = JavaClass.id(o) + + if (ij.i != 1) return "Fail 1" + if (lj.l != 2L) return "Fail 2" + if (aj.a != "string") return "Fail 3" + if (oj.o.i != 3) return "Fail 4" + + 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 6998669dfef..9b1552bf0c6 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java @@ -12145,11 +12145,21 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/inlineClasses/kt28585.kt"); } + @TestMetadata("kt28879.kt") + public void testKt28879() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/kt28879.kt"); + } + @TestMetadata("mapInlineClassesWithSuppressWildcardsMode.kt") public void testMapInlineClassesWithSuppressWildcardsMode() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/mapInlineClassesWithSuppressWildcardsMode.kt"); } + @TestMetadata("mappingOfBoxedFlexibleInlineClassType.kt") + public void testMappingOfBoxedFlexibleInlineClassType() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/mappingOfBoxedFlexibleInlineClassType.kt"); + } + @TestMetadata("noAssertionsOnInlineClassBasedOnNullableType.kt") public void testNoAssertionsOnInlineClassBasedOnNullableType() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/noAssertionsOnInlineClassBasedOnNullableType.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 476c9f814dc..3f44395327c 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -12145,11 +12145,21 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/inlineClasses/kt28585.kt"); } + @TestMetadata("kt28879.kt") + public void testKt28879() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/kt28879.kt"); + } + @TestMetadata("mapInlineClassesWithSuppressWildcardsMode.kt") public void testMapInlineClassesWithSuppressWildcardsMode() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/mapInlineClassesWithSuppressWildcardsMode.kt"); } + @TestMetadata("mappingOfBoxedFlexibleInlineClassType.kt") + public void testMappingOfBoxedFlexibleInlineClassType() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/mappingOfBoxedFlexibleInlineClassType.kt"); + } + @TestMetadata("noAssertionsOnInlineClassBasedOnNullableType.kt") public void testNoAssertionsOnInlineClassBasedOnNullableType() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/noAssertionsOnInlineClassBasedOnNullableType.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java index e131642a1e4..0120c831a4d 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java @@ -12150,11 +12150,21 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/inlineClasses/kt28585.kt"); } + @TestMetadata("kt28879.kt") + public void testKt28879() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/kt28879.kt"); + } + @TestMetadata("mapInlineClassesWithSuppressWildcardsMode.kt") public void testMapInlineClassesWithSuppressWildcardsMode() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/mapInlineClassesWithSuppressWildcardsMode.kt"); } + @TestMetadata("mappingOfBoxedFlexibleInlineClassType.kt") + public void testMappingOfBoxedFlexibleInlineClassType() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/mappingOfBoxedFlexibleInlineClassType.kt"); + } + @TestMetadata("noAssertionsOnInlineClassBasedOnNullableType.kt") public void testNoAssertionsOnInlineClassBasedOnNullableType() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/noAssertionsOnInlineClassBasedOnNullableType.kt"); diff --git a/core/descriptors.jvm/src/org/jetbrains/kotlin/load/kotlin/typeSignatureMapping.kt b/core/descriptors.jvm/src/org/jetbrains/kotlin/load/kotlin/typeSignatureMapping.kt index 5672c22e015..70897a74798 100644 --- a/core/descriptors.jvm/src/org/jetbrains/kotlin/load/kotlin/typeSignatureMapping.kt +++ b/core/descriptors.jvm/src/org/jetbrains/kotlin/load/kotlin/typeSignatureMapping.kt @@ -284,7 +284,7 @@ internal fun computeExpandedTypeInner(kotlinType: KotlinType, visitedClassifiers val underlyingType = kotlinType.substitutedUnderlyingType() ?: return null val expandedUnderlyingType = computeExpandedTypeInner(underlyingType, visitedClassifiers) ?: return null when { - !kotlinType.isMarkedNullable -> expandedUnderlyingType + !kotlinType.isNullable() -> expandedUnderlyingType // Here inline class type is nullable. Apply nullability to the expandedUnderlyingType.