Add "expectedBy" to module descriptor and use it in checker
Now ExpectActualDeclarationChecker in IDE context uses common module descriptors for relevant checks. Compiler still uses own module instead (see comment in checker) So #KT-21771 Fixed
This commit is contained in:
@@ -44,6 +44,7 @@ import org.jetbrains.kotlin.resolve.MultiTargetPlatform
|
||||
import org.jetbrains.kotlin.resolve.TargetEnvironment
|
||||
import org.jetbrains.kotlin.resolve.TargetPlatform
|
||||
import org.jetbrains.kotlin.storage.StorageManager
|
||||
import org.jetbrains.kotlin.storage.getValue
|
||||
import java.util.*
|
||||
import kotlin.coroutines.experimental.buildSequence
|
||||
|
||||
@@ -307,6 +308,10 @@ class LazyModuleDependencies<M : ModuleInfo>(
|
||||
|
||||
override val allDependencies: List<ModuleDescriptorImpl> get() = dependencies()
|
||||
|
||||
override val expectedByDependency by storageManager.createNullableLazyValue {
|
||||
module.expectedBy?.let { resolverForProject.descriptorForModule(it as M) }
|
||||
}
|
||||
|
||||
override val modulesWhoseInternalsAreVisible: Set<ModuleDescriptorImpl>
|
||||
get() =
|
||||
module.modulesWhoseInternalsAreVisible().mapTo(LinkedHashSet()) {
|
||||
|
||||
+6
-4
@@ -110,10 +110,12 @@ object ExpectedActualDeclarationChecker : DeclarationChecker {
|
||||
private fun checkActualDeclarationHasExpected(
|
||||
reportOn: KtNamedDeclaration, descriptor: MemberDescriptor, trace: BindingTrace, checkActual: Boolean
|
||||
) {
|
||||
// Using the platform module instead of the common module is sort of fine here because the former always depends on the latter.
|
||||
// However, it would be clearer to find the common module this platform module implements and look for expected there instead.
|
||||
// TODO: use common module here
|
||||
val compatibility = ExpectedActualResolver.findExpectedForActual(descriptor, descriptor.module) ?: return
|
||||
// TODO: ideally, we should always use common module here
|
||||
// However, in compiler context platform & common modules are joined into one module,
|
||||
// so there is yet no "common module" in this situation.
|
||||
// So yet we are using own module in compiler context and common module in IDE context.
|
||||
val commonOrOwnModule = descriptor.module.expectedByModule ?: descriptor.module
|
||||
val compatibility = ExpectedActualResolver.findExpectedForActual(descriptor, commonOrOwnModule) ?: return
|
||||
|
||||
val hasActualModifier = descriptor.isActual && reportOn.hasActualModifier()
|
||||
if (!hasActualModifier) {
|
||||
|
||||
Reference in New Issue
Block a user