[MPP] allModulesProvidingActualsFor: Support non-hmpp ide case
^KT-50156
This commit is contained in:
committed by
Space
parent
429e1dad9f
commit
ba201a249e
+3
-3
@@ -28,7 +28,7 @@ object ExpectedActualResolver {
|
||||
fun findActualForExpected(
|
||||
expected: MemberDescriptor,
|
||||
platformModule: ModuleDescriptor,
|
||||
moduleVisibilityFilter: ModuleFilter = allModulesProvidingActualsFor(expected.module),
|
||||
moduleVisibilityFilter: ModuleFilter = allModulesProvidingActualsFor(expected.module, platformModule),
|
||||
): Map<ExpectActualCompatibility<MemberDescriptor>, List<MemberDescriptor>>? {
|
||||
return when (expected) {
|
||||
is CallableMemberDescriptor -> {
|
||||
@@ -523,13 +523,13 @@ object ExpectedActualResolver {
|
||||
// FIXME(dsavvinov): review clients, as they won't work properly in HMPP projects
|
||||
@JvmOverloads
|
||||
fun MemberDescriptor.findCompatibleActualsForExpected(
|
||||
platformModule: ModuleDescriptor, moduleFilter: ModuleFilter = allModulesProvidingActualsFor(module)
|
||||
platformModule: ModuleDescriptor, moduleFilter: ModuleFilter = allModulesProvidingActualsFor(module, platformModule)
|
||||
): List<MemberDescriptor> =
|
||||
ExpectedActualResolver.findActualForExpected(this, platformModule, moduleFilter)?.get(Compatible).orEmpty()
|
||||
|
||||
@JvmOverloads
|
||||
fun MemberDescriptor.findAnyActualsForExpected(
|
||||
platformModule: ModuleDescriptor, moduleFilter: ModuleFilter = allModulesProvidingActualsFor(module)
|
||||
platformModule: ModuleDescriptor, moduleFilter: ModuleFilter = allModulesProvidingActualsFor(module, platformModule)
|
||||
): List<MemberDescriptor> {
|
||||
val actualsGroupedByCompatibility = ExpectedActualResolver.findActualForExpected(this, platformModule, moduleFilter)
|
||||
return actualsGroupedByCompatibility?.get(Compatible)
|
||||
|
||||
+22
-2
@@ -19,8 +19,28 @@ fun allModulesProvidingExpectsFor(platformModule: ModuleDescriptor): ModuleFilte
|
||||
it == platformModule || it in platformModule.allExpectedByModules
|
||||
}
|
||||
|
||||
fun allModulesProvidingActualsFor(commonModule: ModuleDescriptor): ModuleFilter = {
|
||||
it == commonModule || commonModule in it.allExpectedByModules
|
||||
/**
|
||||
* @param commonModule: The module for which the allowed modules can provide actuals for.
|
||||
* Meaning that all allowed modules will have declared a dependsOn edge to said [commonModule]
|
||||
*
|
||||
* @param platformModule: This parameter is only required to support pre-hmpp IDE
|
||||
* consumers. In this mode, leaf/platform modules will get wrapped using PlatformModuleInfo which
|
||||
* will be one [ModuleDescriptor] which wrap all dependsOn sources as well.
|
||||
* This module will not declare 'proper' [ModuleDescriptor.allExpectedByModules] to the common module
|
||||
* and therefore has to be passed into this filter as well to manually check if an actual was provided by this module.
|
||||
* This parameter can be dropped and removed once 'non-hmpp' mode shall not be supported anymore.
|
||||
*/
|
||||
fun allModulesProvidingActualsFor(
|
||||
commonModule: ModuleDescriptor,
|
||||
platformModule: ModuleDescriptor
|
||||
): ModuleFilter = { module ->
|
||||
when {
|
||||
module == commonModule -> true
|
||||
commonModule in module.allExpectedByModules -> true
|
||||
/* Support non-hmpp IDE case */
|
||||
module == platformModule -> true
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
|
||||
fun <T : DeclarationDescriptor> Iterable<T>.applyFilter(filter: ModuleFilter): List<T> = filter { filter(it.module) }
|
||||
|
||||
Reference in New Issue
Block a user