@@ -1125,6 +1125,9 @@ enum class DirectlyReferencedTypeLookupFlags {
11251125 // / Include members that would normally be excluded because they come from
11261126 // / modules that have not been imported directly.
11271127 IgnoreMissingImports = 1 << 3 ,
1128+
1129+ // / Whenther we should exclude macro expansions.
1130+ ExcludeMacroExpansions = 1 << 4 ,
11281131};
11291132
11301133using DirectlyReferencedTypeLookupOptions =
@@ -3065,6 +3068,10 @@ static DirectlyReferencedTypeDecls directReferencesForUnqualifiedTypeLookup(
30653068 DirectlyReferencedTypeLookupFlags::IgnoreMissingImports))
30663069 options |= UnqualifiedLookupFlags::IgnoreMissingImports;
30673070
3071+ if (typeLookupOptions.contains (
3072+ DirectlyReferencedTypeLookupFlags::ExcludeMacroExpansions))
3073+ options |= UnqualifiedLookupFlags::ExcludeMacroExpansions;
3074+
30683075 // Manually exclude macro expansions here since the source location
30693076 // is overridden below.
30703077 if (namelookup::isInMacroArgument (dc->getParentSourceFile (), loc))
@@ -3147,6 +3154,10 @@ static llvm::TinyPtrVector<TypeDecl *> directReferencesForQualifiedTypeLookup(
31473154 DirectlyReferencedTypeLookupFlags::IgnoreMissingImports))
31483155 options |= NL_IgnoreMissingImports;
31493156
3157+ if (typeLookupOptions.contains (
3158+ DirectlyReferencedTypeLookupFlags::ExcludeMacroExpansions))
3159+ options |= NL_ExcludeMacroExpansions;
3160+
31503161 // Look through the type declarations we were given, resolving them down
31513162 // to nominal type declarations, module declarations, and
31523163 SmallVector<ModuleDecl *, 2 > moduleDecls;
@@ -3574,7 +3585,8 @@ ProtocolRequirementsRequest::evaluate(Evaluator &evaluator,
35743585
35753586NominalTypeDecl *
35763587ExtendedNominalRequest::evaluate (Evaluator &evaluator,
3577- ExtensionDecl *ext) const {
3588+ ExtensionDecl *ext,
3589+ bool excludeMacroExpansions) const {
35783590 auto typeRepr = ext->getExtendedTypeRepr ();
35793591 if (!typeRepr) {
35803592 // We must've seen 'extension { ... }' during parsing.
@@ -3583,9 +3595,15 @@ ExtendedNominalRequest::evaluate(Evaluator &evaluator,
35833595
35843596 ASTContext &ctx = ext->getASTContext ();
35853597 auto options = defaultDirectlyReferencedTypeLookupOptions;
3598+
35863599 if (ext->isInSpecializeExtensionContext ()) {
35873600 options |= DirectlyReferencedTypeLookupFlags::AllowUsableFromInline;
35883601 }
3602+
3603+ if (excludeMacroExpansions) {
3604+ options |= DirectlyReferencedTypeLookupFlags::ExcludeMacroExpansions;
3605+ }
3606+
35893607 DirectlyReferencedTypeDecls referenced = directReferencesForTypeRepr (
35903608 evaluator, ctx, typeRepr, ext->getParent (), options);
35913609
0 commit comments