@@ -1125,6 +1125,9 @@ enum class DirectlyReferencedTypeLookupFlags {
1125
1125
// / Include members that would normally be excluded because they come from
1126
1126
// / modules that have not been imported directly.
1127
1127
IgnoreMissingImports = 1 << 3 ,
1128
+
1129
+ // / Whenther we should exclude macro expansions.
1130
+ ExcludeMacroExpansions = 1 << 4 ,
1128
1131
};
1129
1132
1130
1133
using DirectlyReferencedTypeLookupOptions =
@@ -3065,6 +3068,10 @@ static DirectlyReferencedTypeDecls directReferencesForUnqualifiedTypeLookup(
3065
3068
DirectlyReferencedTypeLookupFlags::IgnoreMissingImports))
3066
3069
options |= UnqualifiedLookupFlags::IgnoreMissingImports;
3067
3070
3071
+ if (typeLookupOptions.contains (
3072
+ DirectlyReferencedTypeLookupFlags::ExcludeMacroExpansions))
3073
+ options |= UnqualifiedLookupFlags::ExcludeMacroExpansions;
3074
+
3068
3075
// Manually exclude macro expansions here since the source location
3069
3076
// is overridden below.
3070
3077
if (namelookup::isInMacroArgument (dc->getParentSourceFile (), loc))
@@ -3147,6 +3154,10 @@ static llvm::TinyPtrVector<TypeDecl *> directReferencesForQualifiedTypeLookup(
3147
3154
DirectlyReferencedTypeLookupFlags::IgnoreMissingImports))
3148
3155
options |= NL_IgnoreMissingImports;
3149
3156
3157
+ if (typeLookupOptions.contains (
3158
+ DirectlyReferencedTypeLookupFlags::ExcludeMacroExpansions))
3159
+ options |= NL_ExcludeMacroExpansions;
3160
+
3150
3161
// Look through the type declarations we were given, resolving them down
3151
3162
// to nominal type declarations, module declarations, and
3152
3163
SmallVector<ModuleDecl *, 2 > moduleDecls;
@@ -3574,7 +3585,8 @@ ProtocolRequirementsRequest::evaluate(Evaluator &evaluator,
3574
3585
3575
3586
NominalTypeDecl *
3576
3587
ExtendedNominalRequest::evaluate (Evaluator &evaluator,
3577
- ExtensionDecl *ext) const {
3588
+ ExtensionDecl *ext,
3589
+ bool excludeMacroExpansions) const {
3578
3590
auto typeRepr = ext->getExtendedTypeRepr ();
3579
3591
if (!typeRepr) {
3580
3592
// We must've seen 'extension { ... }' during parsing.
@@ -3583,9 +3595,15 @@ ExtendedNominalRequest::evaluate(Evaluator &evaluator,
3583
3595
3584
3596
ASTContext &ctx = ext->getASTContext ();
3585
3597
auto options = defaultDirectlyReferencedTypeLookupOptions;
3598
+
3586
3599
if (ext->isInSpecializeExtensionContext ()) {
3587
3600
options |= DirectlyReferencedTypeLookupFlags::AllowUsableFromInline;
3588
3601
}
3602
+
3603
+ if (excludeMacroExpansions) {
3604
+ options |= DirectlyReferencedTypeLookupFlags::ExcludeMacroExpansions;
3605
+ }
3606
+
3589
3607
DirectlyReferencedTypeDecls referenced = directReferencesForTypeRepr (
3590
3608
evaluator, ctx, typeRepr, ext->getParent (), options);
3591
3609
0 commit comments