Sema: Fix a few issues with the diagnostics on imports with an ambiguous implicit access-level #80314
+76 −29
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
Fix a few issues with the diagnostics pointing out imports with an implicit access-level defaulting to public when the same target is imported non-public somewhere else in the module. These imports may be problematic as they could inadvertently make public a dependency meant to be hidden.
Report at most one error on an implicit import per target across the module, and keep noting all conflicting imports with an explicitly non-public access level. This may leave some implicit imports without an error but that remains in line with other similar diagnostics and is hopefully easier to parse for the user who just added either one implicit or one explicit import.
Fix the diagnostics not always being raised depending on the file ordering. The call on
findInconsistentImportsAcrossModuleused the explicit import as anchor for the check. However since #74035 we skip reporting ambiguity with public imports. So if the anchor was the public import we may ignore an implicit import that would otherwise match against a different non-public explicit import. Invert the predicate for the diagnostic to be reliably raised as expected, no matter the file ordering.rdar://144615496