Skip to content

Commit d51d844

Browse files
committed
Do 'bindExtensions()' as a part of 'performParseAndNameBindingOnly()'
1 parent f6a76f5 commit d51d844

File tree

5 files changed

+20
-22
lines changed

5 files changed

+20
-22
lines changed

include/swift/Sema/IDETypeChecking.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@ namespace swift {
4646
class ValueDecl;
4747
struct PrintOptions;
4848

49-
void bindExtensions(SourceFile &SF);
50-
5149
/// Typecheck binding initializer at \p bindingIndex.
5250
void typeCheckPatternBinding(PatternBindingDecl *PBD, unsigned bindingIndex);
5351

include/swift/Subsystems.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,9 @@ namespace swift {
199199
/// \returns a reference to the type checker instance.
200200
TypeChecker &createTypeChecker(ASTContext &Ctx);
201201

202+
/// Bind all 'extension' visible from \p SF to the extended nominal.
203+
void bindExtensions(SourceFile &SF);
204+
202205
/// Once parsing and name-binding are complete, this walks the AST to resolve
203206
/// types and diagnose problems therein.
204207
///

lib/Frontend/Frontend.cpp

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -843,18 +843,13 @@ void CompilerInstance::parseAndCheckTypesUpTo(
843843
}) && "some files have not yet had their imports resolved");
844844
MainModule->setHasResolvedImports();
845845

846-
// If the limiting AST stage is name binding, we're done.
847-
if (limitStage <= SourceFile::NameBound) {
848-
if (Invocation.isCodeCompletion()) {
849-
performCodeCompletionSecondPass(*PersistentState.get(),
850-
*Invocation.getCodeCompletionFactory());
851-
}
852-
return;
853-
}
854-
assert(!Invocation.isCodeCompletion());
855-
856846
const auto &options = Invocation.getFrontendOptions();
857847
forEachFileToTypeCheck([&](SourceFile &SF) {
848+
if (limitStage == SourceFile::NameBound) {
849+
bindExtensions(SF);
850+
return;
851+
}
852+
858853
performTypeChecking(SF, PersistentState->getTopLevelContext(),
859854
TypeCheckOptions, /*curElem*/ 0,
860855
options.WarnLongFunctionBodies,
@@ -875,6 +870,17 @@ void CompilerInstance::parseAndCheckTypesUpTo(
875870
}
876871
});
877872

873+
if (Invocation.isCodeCompletion()) {
874+
assert(limitStage == SourceFile::NameBound);
875+
performCodeCompletionSecondPass(*PersistentState.get(),
876+
*Invocation.getCodeCompletionFactory());
877+
}
878+
879+
// If the limiting AST stage is name binding, we're done.
880+
if (limitStage <= SourceFile::NameBound) {
881+
return;
882+
}
883+
878884
finishTypeChecking(TypeCheckOptions);
879885
}
880886

@@ -986,6 +992,7 @@ void CompilerInstance::parseAndTypeCheckMainFileUpTo(
986992
llvm_unreachable("invalid limit stage");
987993
case SourceFile::NameBound:
988994
performNameBinding(MainFile, CurTUElem);
995+
bindExtensions(MainFile);
989996
break;
990997
case SourceFile::TypeChecked:
991998
const auto &options = Invocation.getFrontendOptions();

lib/IDE/ExprContextAnalysis.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,6 @@ void typeCheckContextImpl(DeclContext *DC, SourceLoc Loc) {
9191
} // anonymous namespace
9292

9393
void swift::ide::typeCheckContextUntil(DeclContext *DC, SourceLoc Loc) {
94-
// Lookup the swift module. This ensures that we record all known
95-
// protocols in the AST.
96-
(void) DC->getASTContext().getStdlibModule();
97-
98-
bindExtensions(*DC->getParentSourceFile());
99-
10094
while (isa<AbstractClosureExpr>(DC))
10195
DC = DC->getParent();
10296

lib/Sema/TypeChecker.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -385,10 +385,6 @@ void swift::performTypeChecking(SourceFile &SF, TopLevelContext &TLC,
385385
if (!SF.getParentModule()->isOnoneSupportModule())
386386
TC.setSkipNonInlinableBodies(true);
387387

388-
// Lookup the swift module. This ensures that we record all known
389-
// protocols in the AST.
390-
(void) TC.getStdlibModule(&SF);
391-
392388
if (!Ctx.LangOpts.DisableAvailabilityChecking) {
393389
// Build the type refinement hierarchy for the primary
394390
// file before type checking.

0 commit comments

Comments
 (0)