[IR][tests] Add tests for removal-of-abstract-fun IR linkage case
^KT-50771
This commit is contained in:
+5
@@ -0,0 +1,5 @@
|
|||||||
|
package lib1
|
||||||
|
|
||||||
|
abstract class A {
|
||||||
|
abstract fun foo(): Int
|
||||||
|
}
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
package lib1
|
||||||
|
|
||||||
|
open class A
|
||||||
+12
@@ -0,0 +1,12 @@
|
|||||||
|
STEP 0:
|
||||||
|
dependencies: stdlib
|
||||||
|
modifications:
|
||||||
|
U : l1.kt.0 -> l1.kt
|
||||||
|
STEP 1:
|
||||||
|
dependencies: stdlib
|
||||||
|
modifications:
|
||||||
|
U : l1.kt.1 -> l1.kt
|
||||||
|
STEP 2:
|
||||||
|
dependencies: stdlib
|
||||||
|
modifications:
|
||||||
|
U : l1.kt.0 -> l1.kt
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package lib2
|
||||||
|
|
||||||
|
import lib1.A
|
||||||
|
|
||||||
|
class B : A() {
|
||||||
|
override fun foo() = 42
|
||||||
|
}
|
||||||
+5
@@ -0,0 +1,5 @@
|
|||||||
|
package lib2
|
||||||
|
|
||||||
|
import lib1.A
|
||||||
|
|
||||||
|
class B : A()
|
||||||
+6
@@ -0,0 +1,6 @@
|
|||||||
|
STEP 0:
|
||||||
|
dependencies: stdlib, lib1
|
||||||
|
STEP 1:
|
||||||
|
dependencies: stdlib, lib1
|
||||||
|
modifications:
|
||||||
|
U : l2.kt.1 -> l2.kt
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
import lib1.A
|
||||||
|
import lib2.B
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
val a: A = B()
|
||||||
|
|
||||||
|
try {
|
||||||
|
val answer: Int = a.foo() // <-- should throw linkage error here
|
||||||
|
println(answer)
|
||||||
|
} catch (e: Throwable) {
|
||||||
|
if (e.isLinkageError("lib2.B.foo")) return "OK"
|
||||||
|
}
|
||||||
|
|
||||||
|
return "FAIL"
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun Throwable.isLinkageError(symbolName: String): Boolean =
|
||||||
|
this::class.simpleName == "IrLinkageError"
|
||||||
|
&& message == "Abstract function $symbolName is not implemented in non-abstract class ${symbolName.substringBeforeLast(".")}"
|
||||||
+2
@@ -0,0 +1,2 @@
|
|||||||
|
STEP 0:
|
||||||
|
dependencies: stdlib, lib1, lib2
|
||||||
+10
@@ -0,0 +1,10 @@
|
|||||||
|
MODULES: lib1, lib2, main
|
||||||
|
|
||||||
|
STEP 0:
|
||||||
|
libs: lib1, lib2, main
|
||||||
|
|
||||||
|
STEP 1:
|
||||||
|
libs: lib1, lib2
|
||||||
|
|
||||||
|
STEP 2:
|
||||||
|
libs: lib1
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
package lib1
|
||||||
|
|
||||||
|
interface A {
|
||||||
|
fun foo(): Int
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
package lib1
|
||||||
|
|
||||||
|
interface A
|
||||||
+12
@@ -0,0 +1,12 @@
|
|||||||
|
STEP 0:
|
||||||
|
dependencies: stdlib
|
||||||
|
modifications:
|
||||||
|
U : l1.kt.0 -> l1.kt
|
||||||
|
STEP 1:
|
||||||
|
dependencies: stdlib
|
||||||
|
modifications:
|
||||||
|
U : l1.kt.1 -> l1.kt
|
||||||
|
STEP 2:
|
||||||
|
dependencies: stdlib
|
||||||
|
modifications:
|
||||||
|
U : l1.kt.0 -> l1.kt
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package lib2
|
||||||
|
|
||||||
|
import lib1.A
|
||||||
|
|
||||||
|
class B : A {
|
||||||
|
override fun foo() = 42
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
package lib2
|
||||||
|
|
||||||
|
import lib1.A
|
||||||
|
|
||||||
|
class B : A
|
||||||
+6
@@ -0,0 +1,6 @@
|
|||||||
|
STEP 0:
|
||||||
|
dependencies: stdlib, lib1
|
||||||
|
STEP 1:
|
||||||
|
dependencies: stdlib, lib1
|
||||||
|
modifications:
|
||||||
|
U : l2.kt.1 -> l2.kt
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
import lib1.A
|
||||||
|
import lib2.B
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
val a: A = B()
|
||||||
|
|
||||||
|
try {
|
||||||
|
val answer: Int = a.foo() // <-- should throw linkage error here
|
||||||
|
println(answer)
|
||||||
|
} catch (e: Throwable) {
|
||||||
|
if (e.isLinkageError("lib2.B.foo")) return "OK"
|
||||||
|
}
|
||||||
|
|
||||||
|
return "FAIL"
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun Throwable.isLinkageError(symbolName: String): Boolean =
|
||||||
|
this::class.simpleName == "IrLinkageError"
|
||||||
|
&& message == "Abstract function $symbolName is not implemented in non-abstract class ${symbolName.substringBeforeLast(".")}"
|
||||||
+2
@@ -0,0 +1,2 @@
|
|||||||
|
STEP 0:
|
||||||
|
dependencies: stdlib, lib1, lib2
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
MODULES: lib1, lib2, main
|
||||||
|
|
||||||
|
STEP 0:
|
||||||
|
libs: lib1, lib2, main
|
||||||
|
|
||||||
|
STEP 1:
|
||||||
|
libs: lib1, lib2
|
||||||
|
|
||||||
|
STEP 2:
|
||||||
|
libs: lib1
|
||||||
+5
@@ -0,0 +1,5 @@
|
|||||||
|
package lib1
|
||||||
|
|
||||||
|
abstract class A {
|
||||||
|
abstract val foo: Int
|
||||||
|
}
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
package lib1
|
||||||
|
|
||||||
|
open class A
|
||||||
+12
@@ -0,0 +1,12 @@
|
|||||||
|
STEP 0:
|
||||||
|
dependencies: stdlib
|
||||||
|
modifications:
|
||||||
|
U : l1.kt.0 -> l1.kt
|
||||||
|
STEP 1:
|
||||||
|
dependencies: stdlib
|
||||||
|
modifications:
|
||||||
|
U : l1.kt.1 -> l1.kt
|
||||||
|
STEP 2:
|
||||||
|
dependencies: stdlib
|
||||||
|
modifications:
|
||||||
|
U : l1.kt.0 -> l1.kt
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package lib2
|
||||||
|
|
||||||
|
import lib1.A
|
||||||
|
|
||||||
|
class B : A() {
|
||||||
|
override val foo = 42
|
||||||
|
}
|
||||||
+5
@@ -0,0 +1,5 @@
|
|||||||
|
package lib2
|
||||||
|
|
||||||
|
import lib1.A
|
||||||
|
|
||||||
|
class B : A()
|
||||||
+6
@@ -0,0 +1,6 @@
|
|||||||
|
STEP 0:
|
||||||
|
dependencies: stdlib, lib1
|
||||||
|
STEP 1:
|
||||||
|
dependencies: stdlib, lib1
|
||||||
|
modifications:
|
||||||
|
U : l2.kt.1 -> l2.kt
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
import lib1.A
|
||||||
|
import lib2.B
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
val a: A = B()
|
||||||
|
|
||||||
|
try {
|
||||||
|
val answer: Int = a.foo // <-- should throw linkage error here
|
||||||
|
println(answer)
|
||||||
|
} catch (e: Throwable) {
|
||||||
|
if (e.isLinkageError("lib2.B.<get-foo>")) return "OK"
|
||||||
|
}
|
||||||
|
|
||||||
|
return "FAIL"
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun Throwable.isLinkageError(symbolName: String): Boolean =
|
||||||
|
this::class.simpleName == "IrLinkageError"
|
||||||
|
&& message == "Abstract property accessor $symbolName is not implemented in non-abstract class ${symbolName.substringBeforeLast(".")}"
|
||||||
+2
@@ -0,0 +1,2 @@
|
|||||||
|
STEP 0:
|
||||||
|
dependencies: stdlib, lib1, lib2
|
||||||
+10
@@ -0,0 +1,10 @@
|
|||||||
|
MODULES: lib1, lib2, main
|
||||||
|
|
||||||
|
STEP 0:
|
||||||
|
libs: lib1, lib2, main
|
||||||
|
|
||||||
|
STEP 1:
|
||||||
|
libs: lib1, lib2
|
||||||
|
|
||||||
|
STEP 2:
|
||||||
|
libs: lib1
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
package lib1
|
||||||
|
|
||||||
|
interface A {
|
||||||
|
val foo: Int
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
package lib1
|
||||||
|
|
||||||
|
interface A
|
||||||
+12
@@ -0,0 +1,12 @@
|
|||||||
|
STEP 0:
|
||||||
|
dependencies: stdlib
|
||||||
|
modifications:
|
||||||
|
U : l1.kt.0 -> l1.kt
|
||||||
|
STEP 1:
|
||||||
|
dependencies: stdlib
|
||||||
|
modifications:
|
||||||
|
U : l1.kt.1 -> l1.kt
|
||||||
|
STEP 2:
|
||||||
|
dependencies: stdlib
|
||||||
|
modifications:
|
||||||
|
U : l1.kt.0 -> l1.kt
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package lib2
|
||||||
|
|
||||||
|
import lib1.A
|
||||||
|
|
||||||
|
class B : A {
|
||||||
|
override val foo = 42
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
package lib2
|
||||||
|
|
||||||
|
import lib1.A
|
||||||
|
|
||||||
|
class B : A
|
||||||
+6
@@ -0,0 +1,6 @@
|
|||||||
|
STEP 0:
|
||||||
|
dependencies: stdlib, lib1
|
||||||
|
STEP 1:
|
||||||
|
dependencies: stdlib, lib1
|
||||||
|
modifications:
|
||||||
|
U : l2.kt.1 -> l2.kt
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
import lib1.A
|
||||||
|
import lib2.B
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
val a: A = B()
|
||||||
|
|
||||||
|
try {
|
||||||
|
val answer: Int = a.foo // <-- should throw linkage error here
|
||||||
|
println(answer)
|
||||||
|
} catch (e: Throwable) {
|
||||||
|
if (e.isLinkageError("lib2.B.<get-foo>")) return "OK"
|
||||||
|
}
|
||||||
|
|
||||||
|
return "FAIL"
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun Throwable.isLinkageError(symbolName: String): Boolean =
|
||||||
|
this::class.simpleName == "IrLinkageError"
|
||||||
|
&& message == "Abstract property accessor $symbolName is not implemented in non-abstract class ${symbolName.substringBeforeLast(".")}"
|
||||||
+2
@@ -0,0 +1,2 @@
|
|||||||
|
STEP 0:
|
||||||
|
dependencies: stdlib, lib1, lib2
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
MODULES: lib1, lib2, main
|
||||||
|
|
||||||
|
STEP 0:
|
||||||
|
libs: lib1, lib2, main
|
||||||
|
|
||||||
|
STEP 1:
|
||||||
|
libs: lib1, lib2
|
||||||
|
|
||||||
|
STEP 2:
|
||||||
|
libs: lib1
|
||||||
+20
@@ -30,6 +30,26 @@ public class JsKLibABITestCaseGenerated extends AbstractJsKLibABITestCase {
|
|||||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/klibABI"), Pattern.compile("^([^_](.+))$"), null, TargetBackend.JS_IR, false);
|
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/klibABI"), Pattern.compile("^([^_](.+))$"), null, TargetBackend.JS_IR, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("removeAbstractFunctionFromAbstractClass")
|
||||||
|
public void testRemoveAbstractFunctionFromAbstractClass() throws Exception {
|
||||||
|
runTest("compiler/testData/klibABI/removeAbstractFunctionFromAbstractClass/");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("removeAbstractFunctionFromInterface")
|
||||||
|
public void testRemoveAbstractFunctionFromInterface() throws Exception {
|
||||||
|
runTest("compiler/testData/klibABI/removeAbstractFunctionFromInterface/");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("removeAbstractPropertyFromAbstractClass")
|
||||||
|
public void testRemoveAbstractPropertyFromAbstractClass() throws Exception {
|
||||||
|
runTest("compiler/testData/klibABI/removeAbstractPropertyFromAbstractClass/");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("removeAbstractPropertyFromInterface")
|
||||||
|
public void testRemoveAbstractPropertyFromInterface() throws Exception {
|
||||||
|
runTest("compiler/testData/klibABI/removeAbstractPropertyFromInterface/");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("removeClassAsParameterType")
|
@TestMetadata("removeClassAsParameterType")
|
||||||
public void testRemoveClassAsParameterType() throws Exception {
|
public void testRemoveClassAsParameterType() throws Exception {
|
||||||
runTest("compiler/testData/klibABI/removeClassAsParameterType/");
|
runTest("compiler/testData/klibABI/removeClassAsParameterType/");
|
||||||
|
|||||||
Generated
+24
@@ -24,6 +24,30 @@ public class KlibABITestGenerated extends AbstractNativeKlibABITest {
|
|||||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/klibABI"), Pattern.compile("^([^_](.+))$"), null, false);
|
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/klibABI"), Pattern.compile("^([^_](.+))$"), null, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("removeAbstractFunctionFromAbstractClass")
|
||||||
|
public void testRemoveAbstractFunctionFromAbstractClass() throws Exception {
|
||||||
|
runTest("compiler/testData/klibABI/removeAbstractFunctionFromAbstractClass/");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("removeAbstractFunctionFromInterface")
|
||||||
|
public void testRemoveAbstractFunctionFromInterface() throws Exception {
|
||||||
|
runTest("compiler/testData/klibABI/removeAbstractFunctionFromInterface/");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("removeAbstractPropertyFromAbstractClass")
|
||||||
|
public void testRemoveAbstractPropertyFromAbstractClass() throws Exception {
|
||||||
|
runTest("compiler/testData/klibABI/removeAbstractPropertyFromAbstractClass/");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("removeAbstractPropertyFromInterface")
|
||||||
|
public void testRemoveAbstractPropertyFromInterface() throws Exception {
|
||||||
|
runTest("compiler/testData/klibABI/removeAbstractPropertyFromInterface/");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("removeClassAsParameterType")
|
@TestMetadata("removeClassAsParameterType")
|
||||||
public void testRemoveClassAsParameterType() throws Exception {
|
public void testRemoveClassAsParameterType() throws Exception {
|
||||||
|
|||||||
Reference in New Issue
Block a user