Skip to content

Conversation

@xymus
Copy link
Contributor

@xymus xymus commented Mar 26, 2025

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 findInconsistentImportsAcrossModule used 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

xymus added 3 commits March 26, 2025 11:46
Run the check on ambiguous access-levels on imports across files once per module, avoiding repeated errors.
The call on `findInconsistentImportsAcrossModule` used the explicit import as anchor for the check. However since swiftlang#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
… import Report at most one error on an implicit import across the module and keep noting all conflicting explicit imports. 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.
@xymus
Copy link
Contributor Author

xymus commented Mar 26, 2025

@swift-ci Please smoke test

@xymus xymus requested a review from artemcm March 26, 2025 18:48
Revisit the diagnostics around bare imports having a risky implicit default access-level. Lower the error to a warning to make gradual adoption of access-level on imports easier. And reword the note to provide two different solutions to these warnings.
@xymus
Copy link
Contributor Author

xymus commented Apr 3, 2025

@swift-ci please smoke test

@xymus
Copy link
Contributor Author

xymus commented Apr 4, 2025

@swift-ci Please smoke test macOS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants