Use modules instead of files for MPP diagnostic
Using files turned to be a bad idea, because people often use the same name for files with expects and with corresponding actuals. This commits disambiguiates ambiguous message for AMBIGUOUS_ACTUALS/AMBGIUOUS_EXPECTS diagnostics by using modules instead of files ^KT-32582 Fixed
This commit is contained in:
@@ -648,9 +648,9 @@ public interface Errors {
|
||||
DiagnosticFactory2<KtNamedDeclaration, MemberDescriptor,
|
||||
Map<Incompatible, Collection<MemberDescriptor>>> ACTUAL_WITHOUT_EXPECT =
|
||||
DiagnosticFactory2.create(ERROR, INCOMPATIBLE_DECLARATION);
|
||||
DiagnosticFactory2<KtNamedDeclaration, DeclarationDescriptor, Collection<String>> AMBIGUOUS_ACTUALS =
|
||||
DiagnosticFactory2<KtNamedDeclaration, DeclarationDescriptor, Collection<ModuleDescriptor>> AMBIGUOUS_ACTUALS =
|
||||
DiagnosticFactory2.create(ERROR, INCOMPATIBLE_DECLARATION);
|
||||
DiagnosticFactory2<KtNamedDeclaration, DeclarationDescriptor, Collection<String>> AMBIGUOUS_EXPECTS =
|
||||
DiagnosticFactory2<KtNamedDeclaration, DeclarationDescriptor, Collection<ModuleDescriptor>> AMBIGUOUS_EXPECTS =
|
||||
DiagnosticFactory2.create(ERROR, INCOMPATIBLE_DECLARATION);
|
||||
|
||||
DiagnosticFactory2<KtNamedDeclaration, ClassDescriptor,
|
||||
|
||||
+2
-2
@@ -288,9 +288,9 @@ public class DefaultErrorMessages {
|
||||
MAP.put(ACTUAL_WITHOUT_EXPECT, "{0} has no corresponding expected declaration{1}", CAPITALIZED_DECLARATION_NAME_WITH_KIND_AND_PLATFORM,
|
||||
PlatformIncompatibilityDiagnosticRenderer.TEXT);
|
||||
MAP.put(AMBIGUOUS_ACTUALS, "{0} has several compatible actual declarations in modules {1}", CAPITALIZED_DECLARATION_NAME_WITH_KIND_AND_PLATFORM, commaSeparated(
|
||||
STRING));
|
||||
MODULE));
|
||||
MAP.put(AMBIGUOUS_EXPECTS, "{0} has several compatible expect declarations in modules {1}", CAPITALIZED_DECLARATION_NAME_WITH_KIND_AND_PLATFORM, commaSeparated(
|
||||
STRING));
|
||||
MODULE));
|
||||
|
||||
MAP.put(NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS, "Actual class ''{0}'' has no corresponding members for expected class members:{1}",
|
||||
NAME, IncompatibleExpectedActualClassScopesRenderer.TEXT);
|
||||
|
||||
@@ -82,11 +82,16 @@ object Renderers {
|
||||
@JvmField
|
||||
val MODULE_WITH_PLATFORM = Renderer<ModuleDescriptor> { module ->
|
||||
val platform = module.platform
|
||||
val moduleName = module.moduleInfo?.unwrapPlatform()?.displayedName ?: ""
|
||||
val moduleName = MODULE.render(module)
|
||||
val platformNameIfAny = if (platform == null || platform.isCommon()) "" else " for " + platform.single().platformName
|
||||
|
||||
moduleName + platformNameIfAny
|
||||
}
|
||||
|
||||
@JvmField
|
||||
val MODULE = Renderer<ModuleDescriptor> { module ->
|
||||
module.moduleInfo?.unwrapPlatform()?.displayedName ?: module.name.asString()
|
||||
}
|
||||
|
||||
@JvmField
|
||||
val VISIBILITY = Renderer<Visibility> {
|
||||
|
||||
+4
-4
@@ -144,8 +144,8 @@ class ExpectedActualDeclarationChecker(
|
||||
reportOn,
|
||||
descriptor,
|
||||
atLeastWeaklyCompatibleActuals
|
||||
.map { DescriptorUtils.getContainingSourceFile(it).let { it.name ?: it.toString() } }
|
||||
.sorted()
|
||||
.map { it.module }
|
||||
.sortedBy { it.name.asString() }
|
||||
))
|
||||
}
|
||||
}
|
||||
@@ -305,8 +305,8 @@ class ExpectedActualDeclarationChecker(
|
||||
}
|
||||
.map { (_, members) -> members }
|
||||
.flatten()
|
||||
.map { DescriptorUtils.getContainingSourceFile(it).let { it.name ?: it.toString() } }
|
||||
.sorted()
|
||||
.map { it.module }
|
||||
.sortedBy { it.name.asString() }
|
||||
.toList()
|
||||
|
||||
if (filesWithAtLeastWeaklyCompatibleExpects.size > 1) {
|
||||
|
||||
Reference in New Issue
Block a user