@@ -1765,7 +1765,7 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
1765
1765
llvm::StringSet<> ImportedModules;
1766
1766
collectImportedModules (ImportedModules);
1767
1767
1768
- auto mainModuleName = CurrDeclContext-> getParentModule () ->getName ();
1768
+ auto mainModuleName = CurrModule ->getName ();
1769
1769
for (auto ModuleName : ModuleNames) {
1770
1770
if (ModuleName.str ().startswith (" _" ) ||
1771
1771
ModuleName == mainModuleName ||
@@ -1822,8 +1822,7 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
1822
1822
return SemanticContextKind::OutsideNominal;
1823
1823
1824
1824
case DeclVisibilityKind::VisibleAtTopLevel:
1825
- if (CurrDeclContext &&
1826
- D->getModuleContext () == CurrDeclContext->getParentModule ()) {
1825
+ if (CurrDeclContext && D->getModuleContext () == CurrModule) {
1827
1826
// Treat global variables from the same source file as local when
1828
1827
// completing at top-level.
1829
1828
if (isa<VarDecl>(D) && isTopLevelContext (CurrDeclContext) &&
@@ -1936,28 +1935,28 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
1936
1935
// / protocol compositions.
1937
1936
// /
1938
1937
// / FIXME: Perhaps this should be an option in PrintOptions instead.
1939
- Type eraseArchetypes (ModuleDecl *M, Type type, GenericSignature *genericSig) {
1938
+ Type eraseArchetypes (Type type, GenericSignature *genericSig) {
1940
1939
if (!genericSig)
1941
1940
return type;
1942
1941
1943
1942
auto buildProtocolComposition = [&](ArrayRef<ProtocolDecl *> protos) -> Type {
1944
1943
SmallVector<Type, 2 > types;
1945
1944
for (auto proto : protos)
1946
1945
types.push_back (proto->getDeclaredInterfaceType ());
1947
- return ProtocolCompositionType::get (M-> getASTContext () , types,
1946
+ return ProtocolCompositionType::get (Ctx , types,
1948
1947
/* HasExplicitAnyObject=*/ false );
1949
1948
};
1950
1949
1951
1950
if (auto *genericFuncType = type->getAs <GenericFunctionType>()) {
1952
1951
SmallVector<AnyFunctionType::Param, 8 > erasedParams;
1953
1952
for (const auto ¶m : genericFuncType->getParams ()) {
1954
- auto erasedTy = eraseArchetypes (M, param.getPlainType (), genericSig);
1953
+ auto erasedTy = eraseArchetypes (param.getPlainType (), genericSig);
1955
1954
erasedParams.emplace_back (erasedTy, param.getLabel (),
1956
1955
param.getParameterFlags ());
1957
1956
}
1958
1957
return GenericFunctionType::get (genericSig,
1959
1958
erasedParams,
1960
- eraseArchetypes (M, genericFuncType->getResult (), genericSig),
1959
+ eraseArchetypes (genericFuncType->getResult (), genericSig),
1961
1960
genericFuncType->getExtInfo ());
1962
1961
}
1963
1962
@@ -1996,7 +1995,6 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
1996
1995
}
1997
1996
1998
1997
Type getTypeOfMember (const ValueDecl *VD, Type ExprType) {
1999
- auto *M = CurrDeclContext->getParentModule ();
2000
1998
auto *GenericSig = VD->getInnermostDeclContext ()
2001
1999
->getGenericSignatureOfContext ();
2002
2000
@@ -2037,7 +2035,7 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
2037
2035
return T;
2038
2036
2039
2037
// For everything else, substitute in the base type.
2040
- auto Subs = MaybeNominalType->getMemberSubstitutionMap (M , VD);
2038
+ auto Subs = MaybeNominalType->getMemberSubstitutionMap (CurrModule , VD);
2041
2039
2042
2040
// Pass in DesugarMemberTypes so that we see the actual
2043
2041
// concrete type witnesses instead of type alias types.
@@ -2047,7 +2045,7 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
2047
2045
}
2048
2046
}
2049
2047
2050
- return eraseArchetypes (M, T, GenericSig);
2048
+ return eraseArchetypes (T, GenericSig);
2051
2049
}
2052
2050
2053
2051
Type getAssociatedTypeType (const AssociatedTypeDecl *ATD) {
@@ -2307,7 +2305,7 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
2307
2305
2308
2306
if (calleeDC->isLocalContext ())
2309
2307
return SemanticContextKind::Local;
2310
- if (calleeDC->getParentModule () == CurrDeclContext-> getParentModule () )
2308
+ if (calleeDC->getParentModule () == CurrModule )
2311
2309
return SemanticContextKind::CurrentModule;
2312
2310
2313
2311
return SemanticContextKind::OtherModule;
@@ -2318,8 +2316,7 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
2318
2316
foundFunction (AFT);
2319
2317
auto genericSig =
2320
2318
SD->getInnermostDeclContext ()->getGenericSignatureOfContext ();
2321
- AFT = eraseArchetypes (CurrDeclContext->getParentModule (),
2322
- const_cast <AnyFunctionType *>(AFT), genericSig)
2319
+ AFT = eraseArchetypes (const_cast <AnyFunctionType *>(AFT), genericSig)
2323
2320
->castTo <AnyFunctionType>();
2324
2321
2325
2322
CommandWordsPairs Pairs;
@@ -2349,8 +2346,7 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
2349
2346
if (AFD) {
2350
2347
auto genericSig =
2351
2348
AFD->getInnermostDeclContext ()->getGenericSignatureOfContext ();
2352
- AFT = eraseArchetypes (CurrDeclContext->getParentModule (),
2353
- const_cast <AnyFunctionType *>(AFT), genericSig)
2349
+ AFT = eraseArchetypes (const_cast <AnyFunctionType *>(AFT), genericSig)
2354
2350
->castTo <AnyFunctionType>();
2355
2351
}
2356
2352
@@ -3173,7 +3169,7 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
3173
3169
bool tryModuleCompletions (Type ExprType) {
3174
3170
if (auto MT = ExprType->getAs <ModuleType>()) {
3175
3171
ModuleDecl *M = MT->getModule ();
3176
- if (CurrDeclContext-> getParentModule () != M) {
3172
+ if (CurrModule != M) {
3177
3173
// Only use the cache if it is not the current module.
3178
3174
RequestedCachedResults.push_back (
3179
3175
RequestedResultsTy::fromModule (M).needLeadingDot (needDot ()));
@@ -3721,7 +3717,7 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
3721
3717
if (auto NT = T->getAs <NominalType>()) {
3722
3718
if (auto NTD = NT->getDecl ()) {
3723
3719
if (!isa<ProtocolDecl>(NTD) &&
3724
- NTD->getModuleContext () != CurrDeclContext-> getParentModule () ) {
3720
+ NTD->getModuleContext () != CurrModule ) {
3725
3721
addNominalTypeRef (NT->getDecl (),
3726
3722
DeclVisibilityKind::VisibleAtTopLevel, {});
3727
3723
}
@@ -3782,7 +3778,6 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
3782
3778
if (!T->mayHaveMembers ())
3783
3779
return ;
3784
3780
3785
- ModuleDecl *CurrModule = CurrDeclContext->getParentModule ();
3786
3781
DeclContext *DC = const_cast <DeclContext *>(CurrDeclContext);
3787
3782
3788
3783
// We can only say .foo where foo is a static member of the contextual
@@ -3925,10 +3920,8 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
3925
3920
void collectPrecedenceGroups () {
3926
3921
assert (CurrDeclContext);
3927
3922
3928
- auto M = CurrDeclContext->getParentModule ();
3929
-
3930
- if (M) {
3931
- for (auto FU: M->getFiles ()) {
3923
+ if (CurrModule) {
3924
+ for (auto FU: CurrModule->getFiles ()) {
3932
3925
// We are looking through the current module,
3933
3926
// inspect only source files.
3934
3927
if (FU->getKind () != FileUnitKind::Source)
@@ -3944,7 +3937,7 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
3944
3937
CurrDeclContext->getParentSourceFile ()
3945
3938
->forAllVisibleModules ([&](ModuleDecl::ImportedModule Import) {
3946
3939
auto Module = Import.second ;
3947
- if (Module == M )
3940
+ if (Module == CurrModule )
3948
3941
return ;
3949
3942
3950
3943
RequestedCachedResults.push_back (
@@ -3998,9 +3991,9 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
3998
3991
Kind = OnlyTypes ? LookupKind::TypeInDeclContext
3999
3992
: LookupKind::ValueInDeclContext;
4000
3993
NeedLeadingDot = false ;
4001
- ModuleDecl *M = CurrDeclContext->getParentModule ();
4002
3994
AccessFilteringDeclConsumer FilteringConsumer (CurrDeclContext, *this );
4003
- M->lookupVisibleDecls ({}, FilteringConsumer, NLKind::UnqualifiedLookup);
3995
+ CurrModule->lookupVisibleDecls ({}, FilteringConsumer,
3996
+ NLKind::UnqualifiedLookup);
4004
3997
}
4005
3998
4006
3999
void getVisibleDeclsOfModule (const ModuleDecl *TheModule,
0 commit comments