[FIR] Check for subtyping during actualization of supertypes of expect class

^KT-59356 Fixed
This commit is contained in:
Dmitriy Novozhilov
2023-06-16 17:35:01 +03:00
committed by Space Team
parent ac92c129bf
commit 1b24b95cde
26 changed files with 323 additions and 15 deletions
@@ -0,0 +1,31 @@
// IGNORE_BACKEND_K1: ANY
// IGNORE_REASON: new rules for supertypes matching are implemented only in K2
// IGNORE_BACKEND_K2: JS_IR
// IGNORE_REASON: `JsName` in js.translator/testData/_commonFiles/testUtils.kt is invisible for some reason
// IGNORE_BACKEND: WASM
// IGNORE_REASON: wasm tests don't support IGNORE_BACKEND_K1 directive
// LANGUAGE: +MultiPlatformProjects
// ISSUE: KT-59356
// MODULE: common
// FILE: common.kt
open class A {
open fun foo(): String = "Fail"
}
expect class C() : A
fun commonBox(): String {
return C().foo()
}
// MODULE: platform-jvm()()(common)
// FILE: main.kt
open class B : A() {
override fun foo(): String = "OK"
}
actual class C actual constructor() : B()
fun box(): String {
return commonBox()
}
@@ -0,0 +1,39 @@
// TARGET_BACKEND: JVM_IR
// IGNORE_BACKEND_K1: ANY
// IGNORE_REASON: new rules for supertypes matching are implemented only in K2
// LANGUAGE: +MultiPlatformProjects
// ISSUE: KT-59356
// MODULE: common
open class A {
open fun foo(): String = "Fail"
}
expect class C1() : A
expect class C2() : A
fun commonBox(): String {
return C1().foo() + C2().foo()
}
// MODULE: platform-jvm()()(common)
// FILE: A_J.java
public class A_J {}
// FILE: B_J.java
public class B_J extends A_J {
public String foo() { return "O"; }
}
// FILE: C2_J.java
public class C2_J extends B_J {
public String foo() { return "K"; }
}
// FILE: main.kt
actual typealias A = A_J
actual class C1 : B_J()
actual typealias C2 = C2_J
fun box(): String {
return commonBox()
}