Commit Graph

9 Commits

Author SHA1 Message Date
Allan Shortlidge
9aab6ef33e AST: Fix MemberImportVisibility handling of @_exported imports.
In existing Swift, an `@_exported import` in any source file makes the
declarations from the imported module visible in all source files. It's unclear
whether this is an explicit decision or is simply and unintended consequence of
effectively adding an implicit import to each source file for the module being
compiled.

Although it's not clear whether this behavior is desirable, the behavior of
member lookup when the MemberImportVisibility feature is enabled should align
with it in order to avoid causing unnecessary churn in required imports.

Resolves rdar://132525152.
2024-07-26 10:20:41 -07:00
Allan Shortlidge
d002da0ef2 AST: Add a IgnoreMissingImports option to name lookup.
Control enforcement of member import visibility requirements via a new option,
instead of piggy-backing on the existing IgnoreAccessControl option. Adopt the
option when doing fallback lookups for unviable members so that the compiler
can diagnose the reason that a member is inaccessible more reliably.
Previously, with MemberImportVisibility enabled decls with the package access
level could be mis-diagnosed as inaccessible due to their access level when
really they were inaccessible due to a missing import.

Resolves rdar://131501862.
2024-07-10 22:57:15 -07:00
Allan Shortlidge
10a2cde5b4 Tests: Add package access level test cases to MemberImportVisibility tests. 2024-07-10 18:26:01 -07:00
Allan Shortlidge
eba581eec2 AST: Add appropriate attributes to module import fix-its.
Make sure suggested imports are consistent with imports in other files. Also,
make sure the underlying clang module is always imported `@_exported`.
2024-04-16 16:29:51 -07:00
Allan Shortlidge
67b30652f1 Tests: Consolidate inputs for MemberImportVisibility tests.
NFC.
2024-04-16 16:29:51 -07:00
Allan Shortlidge
fa2c900e5b Sema: Diagnose missing imports in during type lookup. 2024-04-16 16:29:51 -07:00
Allan Shortlidge
5ef51d13c4 Sema: Diagnose missing imports in resolveDeclRefExpr(). 2024-04-16 16:29:51 -07:00
Allan Shortlidge
ee4a542ab1 Tests: Improve coverage in members_transitive*.swift.
- Reorganize test cases
- Add tests cases for multi-file and contextual base lookup
- Verify behavior without `MemberImportVisibility` feature

NFC.
2024-04-16 16:29:51 -07:00
Allan Shortlidge
d43816567f AST: Rename ExtensionImportVisibility to MemberImportVisibility.
This feature controls lookup behavior for members in general, not just
extension members.

Resolves rdar://126491324
2024-04-16 16:29:51 -07:00