diff --git a/compiler/testData/klibABI/removeInlinedClass/lib1/l1.kt b/compiler/testData/klibABI/removeInlinedClass/lib1/l1.kt new file mode 100644 index 00000000000..af29f293af1 --- /dev/null +++ b/compiler/testData/klibABI/removeInlinedClass/lib1/l1.kt @@ -0,0 +1 @@ +open class Foo diff --git a/compiler/testData/klibABI/removeInlinedClass/lib1/l1.kt.1 b/compiler/testData/klibABI/removeInlinedClass/lib1/l1.kt.1 new file mode 100644 index 00000000000..cff51601e31 --- /dev/null +++ b/compiler/testData/klibABI/removeInlinedClass/lib1/l1.kt.1 @@ -0,0 +1 @@ +//open class Foo diff --git a/compiler/testData/klibABI/removeInlinedClass/lib1/module.info b/compiler/testData/klibABI/removeInlinedClass/lib1/module.info new file mode 100644 index 00000000000..99edefccd79 --- /dev/null +++ b/compiler/testData/klibABI/removeInlinedClass/lib1/module.info @@ -0,0 +1,6 @@ +STEP 0: + dependencies: stdlib +STEP 1: + dependencies: stdlib + modifications: + U : l1.kt.1 -> l1.kt diff --git a/compiler/testData/klibABI/removeInlinedClass/lib2/l2.kt b/compiler/testData/klibABI/removeInlinedClass/lib2/l2.kt new file mode 100644 index 00000000000..33c3d8ba4b4 --- /dev/null +++ b/compiler/testData/klibABI/removeInlinedClass/lib2/l2.kt @@ -0,0 +1,32 @@ +class Bar : Foo() + +inline fun fooVariableType() { + val foo: Foo? = null + check(foo == null) +} + +inline fun barVariableType() { + val bar: Bar? = null + check(bar == null) +} + +inline fun fooInstance() { + check(Foo().toString() != "Qux") +} + +inline fun barInstance() { + check(Bar().toString() != "Qux") +} + +inline fun fooInstance2() { + check(run(::Foo).toString() != "Qux") +} + +inline fun barInstance2() { + check(run(::Bar).toString() != "Qux") +} + +inline fun fooAnonymousObject() { + val foo = object : Foo() {} + check(foo == null) +} diff --git a/compiler/testData/klibABI/removeInlinedClass/lib2/module.info b/compiler/testData/klibABI/removeInlinedClass/lib2/module.info new file mode 100644 index 00000000000..391aab979a6 --- /dev/null +++ b/compiler/testData/klibABI/removeInlinedClass/lib2/module.info @@ -0,0 +1,2 @@ +STEP 0: + dependencies: stdlib, lib1 \ No newline at end of file diff --git a/compiler/testData/klibABI/removeInlinedClass/main/m.kt b/compiler/testData/klibABI/removeInlinedClass/main/m.kt new file mode 100644 index 00000000000..54790e7d5b4 --- /dev/null +++ b/compiler/testData/klibABI/removeInlinedClass/main/m.kt @@ -0,0 +1,61 @@ +fun box(): String { + try { + fooVariableType() + return "FAIL1" + } catch (e: Throwable) { + if (!e.isUnlinkedTypeOfExpression()) return "FAIL2" + } + + try { + barVariableType() + return "FAIL3" + } catch (e: Throwable) { + if (!e.isUnlinkedTypeOfExpression()) return "FAIL4" + } + + try { + fooInstance() + return "FAIL5" + } catch(e: Throwable) { + if (!e.isUnlinkedSymbolLinkageError("/Foo.")) return "FAIL6" + } + + try { + barInstance() + return "FAIL7" + } catch(e: Throwable) { + if (!e.isUnlinkedTypeInSignature("/Bar.")) return "FAIL8" + } + + try { + fooInstance2() + return "FAIL9" + } catch(e: Throwable) { + if (!e.isUnlinkedSymbolLinkageError("/Foo.")) return "FAIL10" + } + + try { + barInstance2() + return "FAIL11" + } catch(e: Throwable) { + if (!e.isUnlinkedTypeInSignature("/Bar.")) return "FAIL12" + } + + try { + fooAnonymousObject() + return "FAIL13" + } catch(e: Throwable) { + if (!e.isUnlinkedTypeOfExpression()) return "FAIL14" + } + + return "OK" +} + +private fun Throwable.isUnlinkedTypeOfExpression(): Boolean = + this::class.simpleName == "IrLinkageError" && message == "Unlinked type of IR expression" + +private fun Throwable.isUnlinkedSymbolLinkageError(symbolName: String): Boolean = + this::class.simpleName == "IrLinkageError" && message?.startsWith("Unlinked IR symbol $symbolName|") == true + +private fun Throwable.isUnlinkedTypeInSignature(symbolName: String): Boolean = + this::class.simpleName == "IrLinkageError" && message?.startsWith("Unlinked type in signature of IR symbol $symbolName|") == true diff --git a/compiler/testData/klibABI/removeInlinedClass/main/module.info b/compiler/testData/klibABI/removeInlinedClass/main/module.info new file mode 100644 index 00000000000..62f7f4fab07 --- /dev/null +++ b/compiler/testData/klibABI/removeInlinedClass/main/module.info @@ -0,0 +1,2 @@ +STEP 0: + dependencies: stdlib, lib1, lib2 \ No newline at end of file diff --git a/compiler/testData/klibABI/removeInlinedClass/project.info b/compiler/testData/klibABI/removeInlinedClass/project.info new file mode 100644 index 00000000000..2147306d715 --- /dev/null +++ b/compiler/testData/klibABI/removeInlinedClass/project.info @@ -0,0 +1,7 @@ +MODULES: lib1, lib2, main + +STEP 0: + libs: lib1, lib2, main + +STEP 1: + libs: lib1 \ No newline at end of file diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/JsKLibABITestCaseGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/JsKLibABITestCaseGenerated.java index 89beb7c580e..24e8230806c 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/JsKLibABITestCaseGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/JsKLibABITestCaseGenerated.java @@ -75,6 +75,11 @@ public class JsKLibABITestCaseGenerated extends AbstractJsKLibABITestCase { runTest("compiler/testData/klibABI/removeFunction/"); } + @TestMetadata("removeInlinedClass") + public void testRemoveInlinedClass() throws Exception { + runTest("compiler/testData/klibABI/removeInlinedClass/"); + } + @TestMetadata("removeInlinedFunction") public void testRemoveInlinedFunction() throws Exception { runTest("compiler/testData/klibABI/removeInlinedFunction/"); diff --git a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/KlibABITestGenerated.java b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/KlibABITestGenerated.java index 15376f81377..63bd97790a6 100644 --- a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/KlibABITestGenerated.java +++ b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/KlibABITestGenerated.java @@ -78,6 +78,12 @@ public class KlibABITestGenerated extends AbstractNativeKlibABITest { runTest("compiler/testData/klibABI/removeFunction/"); } + @Test + @TestMetadata("removeInlinedClass") + public void testRemoveInlinedClass() throws Exception { + runTest("compiler/testData/klibABI/removeInlinedClass/"); + } + @Test @TestMetadata("removeInlinedFunction") public void testRemoveInlinedFunction() throws Exception {