[SymbolGraphGen] only recurse public-private type aliases from Clang #79996
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves rdar://145980187
In #78959, i added behavior where a public type alias of a type that is hidden to SymbolGraphGen (i.e. through an underscored prefix or with the
@_documentation(visibility:)
attribute) would have synthesized children created by copying them over from the underlying type. However, this code did not account for mutually-recursive type alises, like this:In this case, the code will continuously find new "public-private type aliases" and infinitely recurse until it overflows the stack.
In order to guard against this pattern, this PR changes the behavior to only perform this recursion for symbols imported from Clang, specifically in the
typedef struct
pattern highlighted in #78959. This will limit the impact of the recursion only to symbols that are themselves written deeply nested in the source, and should make this kind of mutual-recursion impossible (or at least much less common).Aside: Alternatives considered
There are a couple alternate approaches i could take with this:
The version in this PR feels the most semantically correct, and matches the behavior in Clang ExtractAPI. I would like to incorporate Option 3, but i didn't do it in this PR because i couldn't think of a way to semantically silence the warning while leaving the above pattern intact. I don't want to introduce an unactionable warning for when this situation is deliberately written and the public type alias is actually desired and/or necessary. (And i don't want to introduce a dedicated "silence this warning" variant of the
@_documentation
attribute because i feel like it breaks the spirit of not having dedicated warning-silencing machinery in Swift writ large.)