From 2476d1bbb6b53792d736268d5646df300f18e917 Mon Sep 17 00:00:00 2001 From: Dmitriy Dolovov Date: Mon, 23 May 2022 16:10:26 +0300 Subject: [PATCH] [IR][tests] Extend test for IR linkage issues related to functions --- .../klibABI/removeFunction/lib1/l1.kt | 8 +++++--- .../klibABI/removeFunction/lib1/l1.kt.1 | 6 ++++-- .../klibABI/removeFunction/lib2/l2.kt | 4 ++-- .../testData/klibABI/removeFunction/main/m.kt | 19 ++++++++++++++++--- 4 files changed, 27 insertions(+), 10 deletions(-) diff --git a/compiler/testData/klibABI/removeFunction/lib1/l1.kt b/compiler/testData/klibABI/removeFunction/lib1/l1.kt index 10a731012f4..f2041daa443 100644 --- a/compiler/testData/klibABI/removeFunction/lib1/l1.kt +++ b/compiler/testData/klibABI/removeFunction/lib1/l1.kt @@ -1,5 +1,7 @@ - - fun foo(): String = "FAIL1" +fun exp_foo(): String = "FAIL2" -fun exp_foo() = "FAIL2" \ No newline at end of file +class A { + fun foo(): String = "FAIL3" + fun exp_foo(): String = "FAIL4" +} diff --git a/compiler/testData/klibABI/removeFunction/lib1/l1.kt.1 b/compiler/testData/klibABI/removeFunction/lib1/l1.kt.1 index 39c9a4e810e..cd7a190788f 100644 --- a/compiler/testData/klibABI/removeFunction/lib1/l1.kt.1 +++ b/compiler/testData/klibABI/removeFunction/lib1/l1.kt.1 @@ -1,3 +1,5 @@ +fun foo(): String = "OK" - -fun foo(): String = "K" \ No newline at end of file +class A { + fun foo(): String = "OK" +} diff --git a/compiler/testData/klibABI/removeFunction/lib2/l2.kt b/compiler/testData/klibABI/removeFunction/lib2/l2.kt index e1961961861..69665aac102 100644 --- a/compiler/testData/klibABI/removeFunction/lib2/l2.kt +++ b/compiler/testData/klibABI/removeFunction/lib2/l2.kt @@ -1,2 +1,2 @@ - -fun qux(exp: Boolean): String = if (exp) exp_foo() else foo() \ No newline at end of file +fun qux(exp: Boolean): String = if (exp) exp_foo() else foo() +fun qux2(exp: Boolean): String = if (exp) A().exp_foo() else A().foo() diff --git a/compiler/testData/klibABI/removeFunction/main/m.kt b/compiler/testData/klibABI/removeFunction/main/m.kt index 6f8825bde03..599f55d605f 100644 --- a/compiler/testData/klibABI/removeFunction/main/m.kt +++ b/compiler/testData/klibABI/removeFunction/main/m.kt @@ -2,16 +2,29 @@ fun test1(): String { try { return qux(true) } catch(e: Throwable) { - if (e.isLinkageError("/exp_foo")) return "O" + if (e.isLinkageError("/exp_foo")) return "OK" } - return "FAIL2" + return "FAIL5" } fun test2(): String = qux(false) +fun test3(): String { + try { + return qux2(true) + } catch(e: Throwable) { + if (e.isLinkageError("/A.exp_foo")) return "OK" + } + + return "FAIL6" +} + +fun test4(): String = qux2(false) + fun box(): String { - return test1() + test2() + val result = test1() + test2() + test3() + test4() + return if (result == "OKOKOKOK") "OK" else result } private fun Throwable.isLinkageError(symbolName: String): Boolean =