[FIR2IR] Always look for already generated fake overrides before creating them
This change covers the case where some f/o was generated in common module and it is referenced in platform code. But signature of this f/o may be different in different modules because of e.g. actualization of value parameters with actual typealias ^KT-60850 Fixed
This commit is contained in:
committed by
Space Team
parent
380062c511
commit
4e3dbcada3
+42
@@ -0,0 +1,42 @@
|
||||
// LANGUAGE: +MultiPlatformProjects
|
||||
// IGNORE_BACKEND_K1: ANY
|
||||
// ISSUE: KT-60850
|
||||
// WITH_STDLIB
|
||||
|
||||
// MODULE: common
|
||||
// FILE: common.kt
|
||||
|
||||
expect class Expect {
|
||||
fun foo(): String
|
||||
}
|
||||
|
||||
interface Base {
|
||||
fun cancel(s: Expect? = null): String
|
||||
}
|
||||
|
||||
open class Derived : Base {
|
||||
override fun cancel(s: Expect?): String {
|
||||
return s?.foo() ?: "OK"
|
||||
}
|
||||
}
|
||||
|
||||
open class AbstractImpl : Derived(), Base
|
||||
|
||||
// MODULE: platform()()(common)
|
||||
// FILE: platform.kt
|
||||
|
||||
class ActualTarget {
|
||||
fun foo(): String = "Fail"
|
||||
}
|
||||
|
||||
actual typealias Expect = ActualTarget
|
||||
|
||||
class Impl : AbstractImpl() {
|
||||
fun test(): String {
|
||||
return cancel()
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return Impl().test()
|
||||
}
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
// LANGUAGE: +MultiPlatformProjects
|
||||
// IGNORE_BACKEND_K1: ANY
|
||||
// ISSUE: KT-60850
|
||||
// WITH_STDLIB
|
||||
|
||||
// MODULE: common
|
||||
// FILE: common.kt
|
||||
|
||||
expect class Expect {
|
||||
fun foo(): String
|
||||
}
|
||||
|
||||
interface Base {
|
||||
fun cancel(s: Expect? = null): String
|
||||
}
|
||||
|
||||
open class Derived : Base {
|
||||
override fun cancel(s: Expect?): String {
|
||||
return s?.foo() ?: "OK"
|
||||
}
|
||||
}
|
||||
|
||||
open class AbstractImpl : Derived(), Base
|
||||
|
||||
fun testCommon(): String {
|
||||
class LocalCommon : AbstractImpl() {
|
||||
fun test(): String {
|
||||
return cancel()
|
||||
}
|
||||
}
|
||||
return LocalCommon().test()
|
||||
}
|
||||
|
||||
// MODULE: platform()()(common)
|
||||
// FILE: platform.kt
|
||||
|
||||
class ActualTarget {
|
||||
fun foo(): String = "Fail"
|
||||
}
|
||||
|
||||
fun testPlatform(): String {
|
||||
class LocalPlatform : AbstractImpl() {
|
||||
fun test(): String {
|
||||
return cancel()
|
||||
}
|
||||
}
|
||||
return LocalPlatform().test()
|
||||
}
|
||||
|
||||
actual typealias Expect = ActualTarget
|
||||
|
||||
fun box(): String {
|
||||
if (testCommon() != "OK") return "Fail"
|
||||
return testPlatform()
|
||||
}
|
||||
Reference in New Issue
Block a user