Skip to content

[6.2] [SymbolGraphGen] distinguish between headers of the same name in different modules #82120

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
merged 1 commit into from
Jun 10, 2025

Conversation

QuietMisdreavus
Copy link
Contributor

  • Explanation: Makes SymbolGraphGen use fully-qualified module names when comparing modules for determining symbol sources.
  • Scope: Fixes an uncommon bug when extending an Objective-C type using a header with the same name as the source module's header.
  • Issues: rdar://152676102
  • Original PRs: [SymbolGraphGen] distinguish between headers of the same name in different modules #82112
  • Risk: Low. The change does not affect normal compilation, and the change will only affect which symbol graph a symbol is sorted into, and shouldn't introduce any crashes.
  • Testing: Automated tests verify the change.
  • Reviewers: @franklinsch

…erent modules (#82112)

Resolves rdar://152676102

In Objective-C, it's reasonable to sort extensions of your dependency's
types into headers that match the name of that type. However, this runs
into a bug in SymbolGraphGen when it comes time to generate Swift symbol
graphs for that Objective-C code: At the moment, it only differentiates
between modules based on their base name, regardless of their parent
modules (if any). This causes these extensions to be incorrectly sorted
into the _extending module's_ symbol graph, rather than in an extension
symbol graph where it can be displayed with the _extended module_. When
processed with Swift-DocC, it would cause these symbols to disappear.

This PR updates the `areModulesEqual` function used by the
`SymbolGraphASTWalker` to consider the fully-qualified module name for
comparisons, rather than just the module's base name, causing situations
like the test's `Dependency.DependencyClass` and
`HeaderCollision.DependencyClass` to be properly distinguished from each
other.
@QuietMisdreavus QuietMisdreavus requested a review from a team as a code owner June 9, 2025 21:23
@QuietMisdreavus
Copy link
Contributor Author

@swift-ci Please test

@QuietMisdreavus QuietMisdreavus enabled auto-merge (squash) June 10, 2025 17:06
Copy link
Contributor

@nkcsgexi nkcsgexi 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 to me a safe change to take.

@QuietMisdreavus QuietMisdreavus merged commit 879cbf6 into release/6.2 Jun 10, 2025
5 checks passed
@QuietMisdreavus QuietMisdreavus deleted the vgm/6.2/clash-of-the-headers branch June 10, 2025 17:11
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.

2 participants