Skip to content

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

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 9, 2025

Conversation

QuietMisdreavus
Copy link
Contributor

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
Copy link
Contributor Author

@swift-ci Please smoke test

@QuietMisdreavus QuietMisdreavus merged commit 0cc4676 into main Jun 9, 2025
3 checks passed
@QuietMisdreavus QuietMisdreavus deleted the vgm/clash-of-the-headers branch June 9, 2025 21:11
QuietMisdreavus added a commit that referenced this pull request Jun 9, 2025
…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 added a commit that referenced this pull request Jun 10, 2025
…n different modules (#82120)

- **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**: #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
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