diff --git a/compiler/testData/klibABI/removeClassAsParameterType/lib1/l1.kt b/compiler/testData/klibABI/removeClassAsParameterType/lib1/l1.kt index 43ec2dd1bcb..c8e529060f6 100644 --- a/compiler/testData/klibABI/removeClassAsParameterType/lib1/l1.kt +++ b/compiler/testData/klibABI/removeClassAsParameterType/lib1/l1.kt @@ -1,4 +1,2 @@ - class C - -class E \ No newline at end of file +class E diff --git a/compiler/testData/klibABI/removeClassAsParameterType/lib1/l1.kt.1 b/compiler/testData/klibABI/removeClassAsParameterType/lib1/l1.kt.1 index 2f3e3fdb38d..826a1a5bc2e 100644 --- a/compiler/testData/klibABI/removeClassAsParameterType/lib1/l1.kt.1 +++ b/compiler/testData/klibABI/removeClassAsParameterType/lib1/l1.kt.1 @@ -1,3 +1 @@ - - -class C \ No newline at end of file +class C diff --git a/compiler/testData/klibABI/removeClassAsParameterType/lib2/l2.kt b/compiler/testData/klibABI/removeClassAsParameterType/lib2/l2.kt index 46687e30fe5..112d4428327 100644 --- a/compiler/testData/klibABI/removeClassAsParameterType/lib2/l2.kt +++ b/compiler/testData/klibABI/removeClassAsParameterType/lib2/l2.kt @@ -1,10 +1,7 @@ - - - class D { - fun foo(): String = stable(C()) fun stable(c: C): String = "K" + fun foo(): String = stable(C()) - fun bar(): String = exp(E()) fun exp(e: E): String = "FAIL1" -} \ No newline at end of file + fun bar(): String = exp(E()) +} diff --git a/compiler/testData/klibABI/removeClassAsParameterType/main/m.kt b/compiler/testData/klibABI/removeClassAsParameterType/main/m.kt index 36d477bded6..683dc272309 100644 --- a/compiler/testData/klibABI/removeClassAsParameterType/main/m.kt +++ b/compiler/testData/klibABI/removeClassAsParameterType/main/m.kt @@ -1,4 +1,3 @@ - fun test1(d: D): String { try { d.bar() @@ -13,7 +12,6 @@ fun test2(d: D): String { return d.foo() } - fun box(): String { return test1(D()) + test2(D()) } diff --git a/compiler/testData/klibABI/removeClassAsReturnType/lib1/l1.kt b/compiler/testData/klibABI/removeClassAsReturnType/lib1/l1.kt index 5331a7cfadc..f83069ebce2 100644 --- a/compiler/testData/klibABI/removeClassAsReturnType/lib1/l1.kt +++ b/compiler/testData/klibABI/removeClassAsReturnType/lib1/l1.kt @@ -1,8 +1,9 @@ - class C { - fun o(): String = "K" + fun o(): String = "O" + val op: String get() = "O" } class E { - fun e(): String = "FAIL" -} \ No newline at end of file + fun e(): String = "FAIL1" + val ep: String get() = "FAIL2" +} diff --git a/compiler/testData/klibABI/removeClassAsReturnType/lib1/l1.kt.1 b/compiler/testData/klibABI/removeClassAsReturnType/lib1/l1.kt.1 index 3f6b66bda3f..c501bba54e7 100644 --- a/compiler/testData/klibABI/removeClassAsReturnType/lib1/l1.kt.1 +++ b/compiler/testData/klibABI/removeClassAsReturnType/lib1/l1.kt.1 @@ -1,4 +1,4 @@ - class C { fun o(): String = "K" + val op: String get() = "K" } diff --git a/compiler/testData/klibABI/removeClassAsReturnType/lib2/l2.kt b/compiler/testData/klibABI/removeClassAsReturnType/lib2/l2.kt index c2b2e1e6eb7..2544d4df64e 100644 --- a/compiler/testData/klibABI/removeClassAsReturnType/lib2/l2.kt +++ b/compiler/testData/klibABI/removeClassAsReturnType/lib2/l2.kt @@ -1,10 +1,21 @@ - - - class D { - fun foo(): String = stable().o() - fun stable(): C = C() + fun stableF(): C = C() + fun fooF(): String = stableF().o() - fun bar(): String = exp().e() - fun exp(): E = E() -} \ No newline at end of file + val stableP1: C get() = C() + val fooP1: String get() = stableP1.op + + val stableP2: C = C() + val fooP2: String = stableP1.op + + fun expF(): E = E() + fun barF(): String = expF().e() + + val expP1: E get() = E() + val barP1: String get() = expP1.ep +} + +class D2 { + val expP2: E = E() + val barP2: String = expP2.ep +} diff --git a/compiler/testData/klibABI/removeClassAsReturnType/main/m.kt b/compiler/testData/klibABI/removeClassAsReturnType/main/m.kt index d6b501241bd..a252314b193 100644 --- a/compiler/testData/klibABI/removeClassAsReturnType/main/m.kt +++ b/compiler/testData/klibABI/removeClassAsReturnType/main/m.kt @@ -1,21 +1,45 @@ - fun test1(d: D): String { try { - d.bar() + d.barF() } catch(e: Throwable) { - if (e.isLinkageError("/D.exp")) return "O" + if (e.isLinkageError("/D.expF")) return "O" } - return "FAIL2" + return "FAIL3" } fun test2(d: D): String { - return d.foo() + return d.fooF() } +fun test3(d: D): String { + try { + d.barP1 + } catch(e: Throwable) { + if (e.isLinkageError("/D.expP1.")) return "O" + } + + return "FAIL4" +} + +fun test4(d: D): String { + return d.fooP1 +} + +fun test5(): String { + try { + D2().barP2 + } catch(e: Throwable) { + if (e.isLinkageError("/D2.expP2.")) return "OK" + else throw e + } + + return "FAIL5" +} fun box(): String { - return test1(D()) + test2(D()) + val result = test1(D()) + test2(D()) + test3(D()) + test4(D()) + test5() + return if (result == "OKOKOK") "OK" else result } private fun Throwable.isLinkageError(symbolName: String): Boolean = diff --git a/compiler/testData/klibABI/removeClassAsSuperTypeArgument/lib1/l1.kt b/compiler/testData/klibABI/removeClassAsSuperTypeArgument/lib1/l1.kt index 5331a7cfadc..37abf18ba4f 100644 --- a/compiler/testData/klibABI/removeClassAsSuperTypeArgument/lib1/l1.kt +++ b/compiler/testData/klibABI/removeClassAsSuperTypeArgument/lib1/l1.kt @@ -1,8 +1,7 @@ - class C { fun o(): String = "K" } class E { fun e(): String = "FAIL" -} \ No newline at end of file +} diff --git a/compiler/testData/klibABI/removeClassAsSuperTypeArgument/lib1/l1.kt.1 b/compiler/testData/klibABI/removeClassAsSuperTypeArgument/lib1/l1.kt.1 index 3f6b66bda3f..bc6cac034b8 100644 --- a/compiler/testData/klibABI/removeClassAsSuperTypeArgument/lib1/l1.kt.1 +++ b/compiler/testData/klibABI/removeClassAsSuperTypeArgument/lib1/l1.kt.1 @@ -1,4 +1,3 @@ - class C { fun o(): String = "K" } diff --git a/compiler/testData/klibABI/removeClassAsSuperTypeArgument/lib2/l2.kt b/compiler/testData/klibABI/removeClassAsSuperTypeArgument/lib2/l2.kt index db2fa447922..16a30a95a19 100644 --- a/compiler/testData/klibABI/removeClassAsSuperTypeArgument/lib2/l2.kt +++ b/compiler/testData/klibABI/removeClassAsSuperTypeArgument/lib2/l2.kt @@ -1,4 +1,3 @@ - interface I { val o: T } @@ -12,9 +11,9 @@ class EX: I { } class D { - fun foo(): String = stable().o.o() fun stable(): ST = ST() + fun foo(): String = stable().o.o() - fun bar(): String = exp().o.e() fun exp(): EX = EX() -} \ No newline at end of file + fun bar(): String = exp().o.e() +} diff --git a/compiler/testData/klibABI/removeClassAsSuperTypeArgument/main/m.kt b/compiler/testData/klibABI/removeClassAsSuperTypeArgument/main/m.kt index d6b501241bd..958fad48d33 100644 --- a/compiler/testData/klibABI/removeClassAsSuperTypeArgument/main/m.kt +++ b/compiler/testData/klibABI/removeClassAsSuperTypeArgument/main/m.kt @@ -1,4 +1,3 @@ - fun test1(d: D): String { try { d.bar() @@ -13,7 +12,6 @@ fun test2(d: D): String { return d.foo() } - fun box(): String { return test1(D()) + test2(D()) } diff --git a/compiler/testData/klibABI/removeClassAsTypeArgument/lib1/l1.kt b/compiler/testData/klibABI/removeClassAsTypeArgument/lib1/l1.kt index 5331a7cfadc..37abf18ba4f 100644 --- a/compiler/testData/klibABI/removeClassAsTypeArgument/lib1/l1.kt +++ b/compiler/testData/klibABI/removeClassAsTypeArgument/lib1/l1.kt @@ -1,8 +1,7 @@ - class C { fun o(): String = "K" } class E { fun e(): String = "FAIL" -} \ No newline at end of file +} diff --git a/compiler/testData/klibABI/removeClassAsTypeArgument/lib1/l1.kt.1 b/compiler/testData/klibABI/removeClassAsTypeArgument/lib1/l1.kt.1 index 3f6b66bda3f..bc6cac034b8 100644 --- a/compiler/testData/klibABI/removeClassAsTypeArgument/lib1/l1.kt.1 +++ b/compiler/testData/klibABI/removeClassAsTypeArgument/lib1/l1.kt.1 @@ -1,4 +1,3 @@ - class C { fun o(): String = "K" } diff --git a/compiler/testData/klibABI/removeClassAsTypeArgument/lib2/l2.kt b/compiler/testData/klibABI/removeClassAsTypeArgument/lib2/l2.kt index 316cff43128..4ec92ab3dc1 100644 --- a/compiler/testData/klibABI/removeClassAsTypeArgument/lib2/l2.kt +++ b/compiler/testData/klibABI/removeClassAsTypeArgument/lib2/l2.kt @@ -1,16 +1,15 @@ - interface I { val o: T } class D { - fun foo(): String = stable().o.o() fun stable(): I = object : I { override val o: C = C() } + fun foo(): String = stable().o.o() - fun bar(): String = exp().o.e() fun exp(): I = object : I { override val o: E = E() } -} \ No newline at end of file + fun bar(): String = exp().o.e() +} diff --git a/compiler/testData/klibABI/removeClassAsTypeArgument/main/m.kt b/compiler/testData/klibABI/removeClassAsTypeArgument/main/m.kt index d6b501241bd..958fad48d33 100644 --- a/compiler/testData/klibABI/removeClassAsTypeArgument/main/m.kt +++ b/compiler/testData/klibABI/removeClassAsTypeArgument/main/m.kt @@ -1,4 +1,3 @@ - fun test1(d: D): String { try { d.bar() @@ -13,7 +12,6 @@ fun test2(d: D): String { return d.foo() } - fun box(): String { return test1(D()) + test2(D()) } diff --git a/compiler/testData/klibABI/removeProperty/lib1/l1.kt b/compiler/testData/klibABI/removeProperty/lib1/l1.kt new file mode 100644 index 00000000000..0e1a52aecba --- /dev/null +++ b/compiler/testData/klibABI/removeProperty/lib1/l1.kt @@ -0,0 +1,12 @@ +val foo: String get() = "FAIL1" +val exp_foo: String get() = "FAIL2" + +class A { + val foo: String get() = "FAIL3" + val exp_foo: String get() = "FAIL4" +} + +class B { + val foo: String = "FAIL5" + val exp_foo: String = "FAIL6" +} diff --git a/compiler/testData/klibABI/removeProperty/lib1/l1.kt.1 b/compiler/testData/klibABI/removeProperty/lib1/l1.kt.1 new file mode 100644 index 00000000000..6b214150792 --- /dev/null +++ b/compiler/testData/klibABI/removeProperty/lib1/l1.kt.1 @@ -0,0 +1,9 @@ +val foo: String get() = "OK" + +class A { + val foo: String get() = "OK" +} + +class B { + val foo: String = "OK" +} diff --git a/compiler/testData/klibABI/removeProperty/lib1/module.info b/compiler/testData/klibABI/removeProperty/lib1/module.info new file mode 100644 index 00000000000..99edefccd79 --- /dev/null +++ b/compiler/testData/klibABI/removeProperty/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/removeProperty/lib2/l2.kt b/compiler/testData/klibABI/removeProperty/lib2/l2.kt new file mode 100644 index 00000000000..da7692d7298 --- /dev/null +++ b/compiler/testData/klibABI/removeProperty/lib2/l2.kt @@ -0,0 +1,3 @@ +fun qux(exp: Boolean): String = if (exp) exp_foo else foo +fun qux2(exp: Boolean): String = if (exp) A().exp_foo else A().foo +fun qux3(exp: Boolean): String = if (exp) B().exp_foo else B().foo diff --git a/compiler/testData/klibABI/removeProperty/lib2/module.info b/compiler/testData/klibABI/removeProperty/lib2/module.info new file mode 100644 index 00000000000..391aab979a6 --- /dev/null +++ b/compiler/testData/klibABI/removeProperty/lib2/module.info @@ -0,0 +1,2 @@ +STEP 0: + dependencies: stdlib, lib1 \ No newline at end of file diff --git a/compiler/testData/klibABI/removeProperty/main/m.kt b/compiler/testData/klibABI/removeProperty/main/m.kt new file mode 100644 index 00000000000..6d733b83398 --- /dev/null +++ b/compiler/testData/klibABI/removeProperty/main/m.kt @@ -0,0 +1,43 @@ +fun test1(): String { + try { + return qux(true) + } catch(e: Throwable) { + if (e.isLinkageError("/exp_foo.")) return "OK" + } + + return "FAIL7" +} + +fun test2(): String = qux(false) + +fun test3(): String { + try { + return qux2(true) + } catch(e: Throwable) { + if (e.isLinkageError("/A.exp_foo.")) return "OK" + } + + return "FAIL8" +} + +fun test4(): String = qux2(false) + +fun test5(): String { + try { + return qux3(true) + } catch(e: Throwable) { + if (e.isLinkageError("/B.exp_foo.")) return "OK" + } + + return "FAIL9" +} + +fun test6(): String = qux3(false) + +fun box(): String { + val result = test1() + test2() + test3() + test4() + test5() + test6() + return if (result == "OKOKOKOKOKOK") "OK" else result +} + +private fun Throwable.isLinkageError(symbolName: String): Boolean = + this::class.simpleName == "IrLinkageError" && message?.startsWith("Unlinked IR symbol $symbolName|") == true diff --git a/compiler/testData/klibABI/removeProperty/main/module.info b/compiler/testData/klibABI/removeProperty/main/module.info new file mode 100644 index 00000000000..62f7f4fab07 --- /dev/null +++ b/compiler/testData/klibABI/removeProperty/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/removeProperty/project.info b/compiler/testData/klibABI/removeProperty/project.info new file mode 100644 index 00000000000..2147306d715 --- /dev/null +++ b/compiler/testData/klibABI/removeProperty/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 f9b97233aa7..a4af0c8fc37 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 @@ -74,4 +74,9 @@ public class JsKLibABITestCaseGenerated extends AbstractJsKLibABITestCase { public void testRemoveFunction() throws Exception { runTest("compiler/testData/klibABI/removeFunction/"); } + + @TestMetadata("removeProperty") + public void testRemoveProperty() throws Exception { + runTest("compiler/testData/klibABI/removeProperty/"); + } } 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 70f0470a63f..b9bb0bb9dc3 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 @@ -77,4 +77,10 @@ public class KlibABITestGenerated extends AbstractNativeKlibABITest { public void testRemoveFunction() throws Exception { runTest("compiler/testData/klibABI/removeFunction/"); } + + @Test + @TestMetadata("removeProperty") + public void testRemoveProperty() throws Exception { + runTest("compiler/testData/klibABI/removeProperty/"); + } }