Skip to content

[6.2] MemberImportVisibility bug fixes #80567

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

Merged

Conversation

tshortli
Copy link
Contributor

@tshortli tshortli commented Apr 6, 2025

  • Explanation: First, filter out Obj-C method overrides when they are declared in a module that isn't imported in the source file and the extended type is from a different module. This narrow fix helps ensure that unwanted overrides don't hijack name lookup and cause the compiler to insist that the developer import a module that they don't want to import in order to call an overridden method. Second, add source locations to more implicitly generated AST nodes so that diagnostics about missing imports get rendered correctly for them.
  • Scope: Fixes two bugs that are frequently encountered while adopting the upcoming MemberImportVisibility feature.
  • Issue/Radar: rdar://145329988 and rdar://144535697
  • Original PRs: AST: Filter out some Obj-C overrides when MemberImportVisibility is enabled #80563 and Parse/Sema: Add source locations to implicit code for MemberImportVisibility diagnostics #80560
  • Risk: Low. Filtering out the un-imported Obj-C method overrides should only allow more code to type-check by preventing those overrides from shadowing other overrides that have been imported. And adding source locations to more AST nodes should generally only affect whether diagnostics are emitted at a known source location or not.
  • Testing: New compiler test cases.

tshortli added 4 commits April 6, 2025 09:52
…nabled.

Unlike in Swift, Obj-C allows method overrides to be declared in extensions
(categories), even outside of the module that defines the type that is being
extended. When MemberImportVisibility is enabled, these overrides must be
filtered out to prevent them from hijacking name lookup and causing the
compiler to insist that the module that defines the extension be imported.

Resolves rdar://145329988.
Ensure that source locations are attached to the implicit calls to
`makeIterator()` and `next()` for diagnostics.

Partially resolves rdar://144535697.
Ensure compiler generated calls to `appendLiteral(_:)` have source locations for
diagnostics.

Partially resolves rdar://144535697.
@tshortli
Copy link
Contributor Author

tshortli commented Apr 6, 2025

@swift-ci please test

@tshortli tshortli added 🍒 release cherry pick Flag: Release branch cherry picks swift 6.2 labels Apr 7, 2025
@tshortli tshortli marked this pull request as ready for review April 7, 2025 16:07
@tshortli tshortli requested a review from a team as a code owner April 7, 2025 16:07
@tshortli
Copy link
Contributor Author

tshortli commented Apr 7, 2025

@swift-ci please test

@tshortli tshortli enabled auto-merge April 7, 2025 23:33
@tshortli tshortli merged commit cb444b6 into swiftlang:release/6.2 Apr 8, 2025
5 checks passed
@tshortli tshortli deleted the module-import-visibility-fixes-6.2 branch April 8, 2025 14:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🍒 release cherry pick Flag: Release branch cherry picks swift 6.2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants