@@ -603,7 +603,7 @@ SelfBoundsFromWhereClauseRequest::evaluate(Evaluator &evaluator,
603
603
604
604
static void
605
605
populateLookupDeclsFromContext (DeclContext *dc,
606
- SmallVectorImpl<TypeDecl *> &lookupDecls) {
606
+ SmallVectorImpl<NominalTypeDecl *> &lookupDecls) {
607
607
auto nominal = dc->getSelfNominalTypeDecl ();
608
608
if (!nominal)
609
609
return ;
@@ -831,7 +831,7 @@ UnqualifiedLookup::UnqualifiedLookup(DeclName Name, DeclContext *DC,
831
831
if (!nominal) continue ;
832
832
833
833
// Dig out the type we're looking into.
834
- SmallVector<TypeDecl *, 2 > lookupDecls;
834
+ SmallVector<NominalTypeDecl *, 2 > lookupDecls;
835
835
populateLookupDeclsFromContext (dc, lookupDecls);
836
836
837
837
NLOptions options = baseNLOptions;
@@ -897,7 +897,7 @@ UnqualifiedLookup::UnqualifiedLookup(DeclName Name, DeclContext *DC,
897
897
DeclContext *MetaBaseDC = nullptr ;
898
898
GenericParamList *GenericParams = nullptr ;
899
899
900
- SmallVector<TypeDecl *, 2 > lookupDecls;
900
+ SmallVector<NominalTypeDecl *, 2 > lookupDecls;
901
901
902
902
if (auto *PBI = dyn_cast<PatternBindingInitializer>(DC)) {
903
903
auto *PBD = PBI->getBinding ();
@@ -1940,15 +1940,10 @@ bool DeclContext::lookupQualified(Type type,
1940
1940
SmallVector<NominalTypeDecl *, 4 > nominalTypesToLookInto;
1941
1941
extractDirectlyReferencedNominalTypes (type, nominalTypesToLookInto);
1942
1942
1943
- SmallVector<TypeDecl *, 4 > typeDeclsToLookInto;
1944
- typeDeclsToLookInto.reserve (nominalTypesToLookInto.size ());
1945
- for (auto nominal : nominalTypesToLookInto)
1946
- typeDeclsToLookInto.push_back (nominal);
1947
-
1948
- return lookupQualified (typeDeclsToLookInto, member, options, decls);
1943
+ return lookupQualified (nominalTypesToLookInto, member, options, decls);
1949
1944
}
1950
1945
1951
- bool DeclContext::lookupQualified (ArrayRef<TypeDecl *> typeDecls,
1946
+ bool DeclContext::lookupQualified (ArrayRef<NominalTypeDecl *> typeDecls,
1952
1947
DeclName member,
1953
1948
NLOptions options,
1954
1949
SmallVectorImpl<ValueDecl *> &decls) const {
@@ -1977,38 +1972,17 @@ bool DeclContext::lookupQualified(ArrayRef<TypeDecl *> typeDecls,
1977
1972
return true ;
1978
1973
};
1979
1974
1980
- // Look through the type declarations we were given, resolving them down
1981
- // to nominal type declarations, module declarations, and
1982
- ASTContext &ctx = getASTContext ();
1983
- SmallVector<ModuleDecl *, 2 > moduleDecls;
1984
- bool anyObject = false ;
1985
- auto nominalTypeDecls =
1986
- resolveTypeDeclsToNominal (ctx.evaluator , ctx, typeDecls, moduleDecls,
1987
- anyObject);
1988
-
1989
- // If the only declaration we were given was AnyObject, this is AnyObject
1990
- // lookup.
1991
- if (anyObject && nominalTypeDecls.empty () && moduleDecls.empty ())
1992
- return lookupAnyObject (member, options, decls);
1993
-
1994
1975
// Add all of the nominal types to the stack.
1995
- for (auto nominal : nominalTypeDecls ) {
1976
+ for (auto nominal : typeDecls ) {
1996
1977
addNominalType (nominal);
1997
1978
}
1998
1979
1999
- // Search all of the modules.
2000
- for (auto module : moduleDecls) {
2001
- auto innerOptions = options;
2002
- innerOptions &= ~NL_RemoveOverridden;
2003
- innerOptions &= ~NL_RemoveNonVisible;
2004
- lookupQualified (module , member, innerOptions, decls);
2005
- }
2006
-
2007
1980
// Whether we only want to return complete object initializers.
2008
1981
bool onlyCompleteObjectInits = false ;
2009
1982
2010
1983
// Visit all of the nominal types we know about, discovering any others
2011
1984
// we need along the way.
1985
+ auto &ctx = getASTContext ();
2012
1986
auto typeResolver = ctx.getLazyResolver ();
2013
1987
bool wantProtocolMembers = (options & NL_ProtocolMembers);
2014
1988
while (!stack.empty ()) {
@@ -2344,7 +2318,25 @@ directReferencesForQualifiedTypeLookup(Evaluator &evaluator,
2344
2318
// Look into the base types.
2345
2319
SmallVector<ValueDecl *, 4 > members;
2346
2320
auto options = NL_RemoveNonVisible | NL_OnlyTypes;
2347
- dc->lookupQualified (baseTypes, name, options, members);
2321
+
2322
+ // Look through the type declarations we were given, resolving them down
2323
+ // to nominal type declarations, module declarations, and
2324
+ SmallVector<ModuleDecl *, 2 > moduleDecls;
2325
+ bool anyObject = false ;
2326
+ auto nominalTypeDecls =
2327
+ resolveTypeDeclsToNominal (ctx.evaluator , ctx, baseTypes, moduleDecls,
2328
+ anyObject);
2329
+
2330
+ dc->lookupQualified (nominalTypeDecls, name, options, members);
2331
+
2332
+ // Search all of the modules.
2333
+ for (auto module : moduleDecls) {
2334
+ auto innerOptions = options;
2335
+ innerOptions &= ~NL_RemoveOverridden;
2336
+ innerOptions &= ~NL_RemoveNonVisible;
2337
+ dc->lookupQualified (module , name, innerOptions, members);
2338
+ }
2339
+
2348
2340
addResults (members);
2349
2341
}
2350
2342
0 commit comments