[IDE] Only consider synthesized extensions when in the same module

Only declarations in the same module as synthesized extension's target
are placed within a synthesized extension. We should thus not add
"::SYNTHESIZED::" to the USR if the given declaration is in a different
and.

As an example, `Foundation` adds a method `components(separatedBy:)` to
`String` through an extension on `StringProtocol`. But since it is
within `Foundation` and not `Swift` it will *not* be in a synthesized
extension of `String` or `StringProtocol`. So it should not have
"::SYNTHESIZED::" added and should also not being in the `String` group.

Resolves rdar://71355632.
This commit is contained in:
Ben Barham
2021-12-15 13:44:07 +10:00
parent b1b6cae7bb
commit bf0bcfa8e1
4 changed files with 102 additions and 29 deletions

View File

@@ -785,6 +785,7 @@ struct DeclInfo {
const ValueDecl *OriginalProperty = nullptr;
bool Unavailable = true;
Type BaseType;
/// Whether the \c VD is in a synthesized extension of \c BaseType
bool InSynthesizedExtension = false;
DeclInfo(const ValueDecl *VD, Type ContainerType, bool IsRef, bool IsDynamic,
@@ -810,9 +811,8 @@ struct DeclInfo {
}
BaseType = findBaseTypeForReplacingArchetype(VD, ContainerType);
InSynthesizedExtension = false;
if (BaseType) {
if (auto Target = BaseType->getAnyNominal()) {
if (auto *Target = BaseType->getAnyNominal()) {
SynthesizedExtensionAnalyzer Analyzer(
Target, PrintOptions::printModuleInterface(
Invoc.getFrontendOptions().PrintFullConvention));