[IR][tests] Add tests for IR linkage issues related to properties
This commit is contained in:
@@ -1,4 +1,2 @@
|
||||
|
||||
class C
|
||||
|
||||
class E
|
||||
class E
|
||||
|
||||
@@ -1,3 +1 @@
|
||||
|
||||
|
||||
class C
|
||||
class C
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
fun bar(): String = exp(E())
|
||||
}
|
||||
|
||||
@@ -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())
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
fun e(): String = "FAIL1"
|
||||
val ep: String get() = "FAIL2"
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
|
||||
class C {
|
||||
fun o(): String = "K"
|
||||
val op: String get() = "K"
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
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
|
||||
}
|
||||
|
||||
+30
-6
@@ -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.<get-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.<get-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 =
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
|
||||
class C {
|
||||
fun o(): String = "K"
|
||||
}
|
||||
|
||||
class E {
|
||||
fun e(): String = "FAIL"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
class C {
|
||||
fun o(): String = "K"
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
interface I<T> {
|
||||
val o: T
|
||||
}
|
||||
@@ -12,9 +11,9 @@ class EX: I<E> {
|
||||
}
|
||||
|
||||
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()
|
||||
}
|
||||
fun bar(): String = exp().o.e()
|
||||
}
|
||||
|
||||
@@ -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())
|
||||
}
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
|
||||
class C {
|
||||
fun o(): String = "K"
|
||||
}
|
||||
|
||||
class E {
|
||||
fun e(): String = "FAIL"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
class C {
|
||||
fun o(): String = "K"
|
||||
}
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
|
||||
interface I<T> {
|
||||
val o: T
|
||||
}
|
||||
|
||||
class D {
|
||||
fun foo(): String = stable().o.o()
|
||||
fun stable(): I<C> = object : I<C> {
|
||||
override val o: C = C()
|
||||
}
|
||||
fun foo(): String = stable().o.o()
|
||||
|
||||
fun bar(): String = exp().o.e()
|
||||
fun exp(): I<E> = object : I<E> {
|
||||
override val o: E = E()
|
||||
}
|
||||
}
|
||||
fun bar(): String = exp().o.e()
|
||||
}
|
||||
|
||||
@@ -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())
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
val foo: String get() = "OK"
|
||||
|
||||
class A {
|
||||
val foo: String get() = "OK"
|
||||
}
|
||||
|
||||
class B {
|
||||
val foo: String = "OK"
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
STEP 0:
|
||||
dependencies: stdlib
|
||||
STEP 1:
|
||||
dependencies: stdlib
|
||||
modifications:
|
||||
U : l1.kt.1 -> l1.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
|
||||
@@ -0,0 +1,2 @@
|
||||
STEP 0:
|
||||
dependencies: stdlib, lib1
|
||||
@@ -0,0 +1,43 @@
|
||||
fun test1(): String {
|
||||
try {
|
||||
return qux(true)
|
||||
} catch(e: Throwable) {
|
||||
if (e.isLinkageError("/exp_foo.<get-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.<get-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.<get-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
|
||||
@@ -0,0 +1,2 @@
|
||||
STEP 0:
|
||||
dependencies: stdlib, lib1, lib2
|
||||
@@ -0,0 +1,7 @@
|
||||
MODULES: lib1, lib2, main
|
||||
|
||||
STEP 0:
|
||||
libs: lib1, lib2, main
|
||||
|
||||
STEP 1:
|
||||
libs: lib1
|
||||
+5
@@ -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/");
|
||||
}
|
||||
}
|
||||
|
||||
Generated
+6
@@ -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/");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user