Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename ExtensionImportVisibility to MemberImportVisibility and fix bugs #73063

Merged

Conversation

tshortli
Copy link
Contributor

@tshortli tshortli commented Apr 16, 2024

Rename the ExtensionImportVisibility experimental feature introduced in #72060 to MemberImportVisibility. Although extension members are the members that are most often accidentally visible via transitive imports, the effects of enabling the feature are not limited to lookup of members on extensions. The test cases added in this PR provide examples of additional situations where these diagnostics will take effect.

In addition to renaming the experimental feature, this PR also refines the implementation, increases test coverage, and fixes a couple of bugs:

  • Missing imports are now diagnosed during decl ref and type resolution.
  • Appropriate attributes (e.g. @_implementationOnly or @_exported) are now prepended to the import Module fix-it.
  • Missing imports of the bridging header module are no longer diagnosed.

Resolves rdar://126491324 and #46493.

@tshortli tshortli force-pushed the rename-extension-import-visibility-feature branch from e6c75ca to d875291 Compare April 16, 2024 21:28
This feature controls lookup behavior for members in general, not just
extension members.

Resolves rdar://126491324
- Reorganize test cases
- Add tests cases for multi-file and contextual base lookup
- Verify behavior without `MemberImportVisibility` feature

NFC.
Make sure suggested imports are consistent with imports in other files. Also,
make sure the underlying clang module is always imported `@_exported`.
This results in clearer source locations for diagnostics.
@tshortli tshortli force-pushed the rename-extension-import-visibility-feature branch from d875291 to 865c26c Compare April 16, 2024 23:29
@tshortli
Copy link
Contributor Author

@swift-ci please smoke test

@tshortli tshortli requested review from xymus and DougGregor April 16, 2024 23:41
@tshortli tshortli marked this pull request as ready for review April 16, 2024 23:45
@@ -167,9 +167,9 @@ ERROR(init_candidate_inaccessible,none,

ERROR(candidate_from_missing_import,none,
"%0 %1 is not available due to missing import of defining module %2",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

General comment as this wasn't introduced in this PR. Should we try to avoid available here as it points to the availability system, maybe reachable or visible?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that's good feedback. Perhaps we should use the word "inaccessible" which would match the wording of diagnostics about declarations that are unavailable due to access levels.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I expect to continue refining this implementation, so I'll track this as something to re-evaluate in the next PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this should not block this PR. And "inaccessible" sounds good to me.

Copy link
Member

@DougGregor DougGregor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great, thank you!

@tshortli tshortli merged commit 0a2167c into swiftlang:main Apr 17, 2024
3 checks passed
@tshortli tshortli deleted the rename-extension-import-visibility-feature branch April 17, 2024 21:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants