@@ -74,7 +74,6 @@ namespace {
74
74
LookupResult &Result;
75
75
DeclContext *DC;
76
76
NameLookupOptions Options;
77
- bool IsMemberLookup;
78
77
79
78
// / The vector of found declarations.
80
79
SmallVector<ValueDecl *, 4 > FoundDecls;
@@ -86,46 +85,13 @@ namespace {
86
85
87
86
public:
88
87
LookupResultBuilder (LookupResult &result, DeclContext *dc,
89
- NameLookupOptions options,
90
- bool isMemberLookup)
91
- : Result(result), DC(dc), Options(options),
92
- IsMemberLookup (isMemberLookup) {
88
+ NameLookupOptions options)
89
+ : Result(result), DC(dc), Options(options) {
93
90
if (dc->getASTContext ().isAccessControlDisabled ())
94
91
Options |= NameLookupFlags::IgnoreAccessControl;
95
92
}
96
93
97
- // / Determine whether we should filter out the results by removing
98
- // / overridden and shadowed declarations.
99
- // / FIXME: We should *always* do this, but there are weird assumptions
100
- // / about the results of unqualified name lookup, e.g., that a local
101
- // / variable not having a type indicates that it hasn't been seen yet.
102
- bool shouldFilterResults () const {
103
- // Member lookups always filter results.
104
- if (IsMemberLookup) return true ;
105
-
106
- bool allAreInOtherModules = true ;
107
- auto currentModule = DC->getParentModule ();
108
- for (const auto &found : Result) {
109
- // We found a member, so we need to filter.
110
- if (found.getBaseDecl () != nullptr )
111
- return true ;
112
-
113
- // We found something in our own module.
114
- if (found.getValueDecl ()->getDeclContext ()->getParentModule () ==
115
- currentModule)
116
- allAreInOtherModules = false ;
117
- }
118
-
119
- // FIXME: Only perform shadowing if we found things from other modules.
120
- // This prevents us from introducing additional type-checking work
121
- // during name lookup.
122
- return allAreInOtherModules;
123
- }
124
-
125
94
~LookupResultBuilder () {
126
- // Check whether we should do this filtering aat all.
127
- if (!shouldFilterResults ()) return ;
128
-
129
95
// Remove any overridden declarations from the found-declarations set.
130
96
removeOverriddenDecls (FoundDecls);
131
97
removeOverriddenDecls (FoundOuterDecls);
@@ -305,7 +271,7 @@ LookupResult TypeChecker::lookupUnqualified(DeclContext *dc, DeclName name,
305
271
convertToUnqualifiedLookupOptions (options));
306
272
307
273
LookupResult result;
308
- LookupResultBuilder builder (result, dc, options, /* memberLookup */ false );
274
+ LookupResultBuilder builder (result, dc, options);
309
275
for (auto idx : indices (lookup.Results )) {
310
276
const auto &found = lookup.Results [idx];
311
277
// Determine which type we looked through to find this result.
@@ -381,8 +347,7 @@ LookupResult TypeChecker::lookupMember(DeclContext *dc,
381
347
subOptions &= ~NL_RemoveOverridden;
382
348
subOptions &= ~NL_RemoveNonVisible;
383
349
384
- LookupResultBuilder builder (result, dc, options,
385
- /* memberLookup*/ true );
350
+ LookupResultBuilder builder (result, dc, options);
386
351
SmallVector<ValueDecl *, 4 > lookupResults;
387
352
dc->lookupQualified (type, name, subOptions, lookupResults);
388
353
0 commit comments