[FIR] Sort HMPP dependencies topologically for symbol providers

This fixes an issue where an actual class from an intermediate module
has more supertypes than its expect declaration which leads to a
false-positive resolution error because a type reference resolves to the
expect class. The fix is to sort the dependencies topologically from
"most actual" to "most expect" when creating the list of symbol
providers.

#KT-57369 Fixed
This commit is contained in:
Kirill Rakhman
2023-03-22 12:10:48 +01:00
committed by Space Team
parent 6fe0849402
commit 60b227c519
15 changed files with 174 additions and 33 deletions
@@ -0,0 +1,30 @@
// ISSUE: KT-57369
// MODULE: common
// TARGET_PLATFORM: Common
interface CompletionHandler {
fun foo()
}
expect class CompletionHandlerBase()
fun invokeOnCompletion(handler: CompletionHandler) {}
// MODULE: intermediate()()(common)
// TARGET_PLATFORM: Common
// actual has an additional super type
actual class CompletionHandlerBase : CompletionHandler {
override fun foo() {}
}
fun cancelFutureOnCompletionAlt(handlerBase: CompletionHandlerBase) {
invokeOnCompletion(handlerBase)
handlerBase.foo()
}
// MODULE: main()()(common, intermediate)
// the order of dependencies is important to reproduce KT-57369
fun cancelFutureOnCompletion(handlerBase: CompletionHandlerBase) {
invokeOnCompletion(handlerBase)
handlerBase.foo()
}
@@ -0,0 +1,30 @@
// ISSUE: KT-57369
// MODULE: common
// TARGET_PLATFORM: Common
interface CompletionHandler {
fun foo()
}
expect <!EXPECT_AND_ACTUAL_IN_THE_SAME_MODULE{COMMON}!>class CompletionHandlerBase<!>()
fun invokeOnCompletion(handler: CompletionHandler) {}
// MODULE: intermediate()()(common)
// TARGET_PLATFORM: Common
// actual has an additional super type
actual <!EXPECT_AND_ACTUAL_IN_THE_SAME_MODULE!>class CompletionHandlerBase<!> : CompletionHandler {
override fun foo() {}
}
fun cancelFutureOnCompletionAlt(handlerBase: CompletionHandlerBase) {
invokeOnCompletion(handlerBase)
handlerBase.foo()
}
// MODULE: main()()(common, intermediate)
// the order of dependencies is important to reproduce KT-57369
fun cancelFutureOnCompletion(handlerBase: CompletionHandlerBase) {
invokeOnCompletion(handlerBase)
handlerBase.foo()
}