@@ -39,7 +39,8 @@ namespace {
39
39
DeclContext *DC;
40
40
NameLookupOptions Options;
41
41
bool ConsiderProtocolMembers;
42
- bool SearchingFromProtoExt = false ;
42
+ bool SearchingFromProtoExt;
43
+ bool IsMemberLookup;
43
44
44
45
// / The vector of found declarations.
45
46
SmallVector<ValueDecl *, 4 > FoundDecls;
@@ -50,10 +51,11 @@ namespace {
50
51
public:
51
52
LookupResultBuilder (TypeChecker &tc, LookupResult &result, DeclContext *dc,
52
53
NameLookupOptions options, bool considerProtocolMembers,
53
- bool searchingFromProtoExt)
54
+ bool searchingFromProtoExt, bool isMemberLookup )
54
55
: TC(tc), Result(result), DC(dc), Options(options),
55
56
ConsiderProtocolMembers (considerProtocolMembers),
56
- SearchingFromProtoExt(searchingFromProtoExt) { }
57
+ SearchingFromProtoExt(searchingFromProtoExt),
58
+ IsMemberLookup(isMemberLookup) { }
57
59
58
60
~LookupResultBuilder () {
59
61
// If any of the results have a base, we need to remove
@@ -62,7 +64,8 @@ namespace {
62
64
// but there are weird assumptions about the results of unqualified
63
65
// name lookup, e.g., that a local variable not having a type indicates
64
66
// that it hasn't been seen yet.
65
- if (std::find_if (Result.begin (), Result.end (),
67
+ if (!IsMemberLookup &&
68
+ std::find_if (Result.begin (), Result.end (),
66
69
[](const LookupResult::Result &found) {
67
70
return found.Base != nullptr ;
68
71
}) == Result.end ())
@@ -207,7 +210,8 @@ LookupResult TypeChecker::lookupUnqualified(DeclContext *dc, DeclName name,
207
210
= options.contains (NameLookupFlags::ProtocolMembers);
208
211
LookupResultBuilder builder (*this , result, dc, options,
209
212
considerProtocolMembers,
210
- searchingFromProtoExt);
213
+ searchingFromProtoExt,
214
+ /* memberLookup*/ false );
211
215
for (const auto &found : lookup.Results ) {
212
216
// Determine which type we looked through to find this result.
213
217
Type foundInType;
@@ -279,7 +283,8 @@ LookupResult TypeChecker::lookupMember(DeclContext *dc,
279
283
280
284
LookupResultBuilder builder (*this , result, dc, options,
281
285
considerProtocolMembers,
282
- false );
286
+ /* protocol extension*/ false ,
287
+ /* member lookup*/ true );
283
288
SmallVector<ValueDecl *, 4 > lookupResults;
284
289
dc->lookupQualified (type, name, subOptions, this , lookupResults);
285
290
0 commit comments