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