Skip to content

Commit 9208f5b

Browse files
committed
Remove StartElem params from various entry points
Now that REPL code completion no longer injects temporary decls into source files, this parameter is no longer needed.
1 parent 5ed2847 commit 9208f5b

File tree

8 files changed

+23
-43
lines changed

8 files changed

+23
-43
lines changed

include/swift/AST/TypeCheckRequests.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1959,17 +1959,15 @@ class DynamicallyReplacedDeclRequest
19591959

19601960
class TypeCheckSourceFileRequest :
19611961
public SimpleRequest<TypeCheckSourceFileRequest,
1962-
bool (SourceFile *, unsigned),
1963-
CacheKind::SeparatelyCached> {
1962+
bool (SourceFile *), CacheKind::SeparatelyCached> {
19641963
public:
19651964
using SimpleRequest::SimpleRequest;
19661965

19671966
private:
19681967
friend SimpleRequest;
19691968

19701969
// Evaluation.
1971-
llvm::Expected<bool> evaluate(Evaluator &evaluator,
1972-
SourceFile *SF, unsigned StartElem) const;
1970+
llvm::Expected<bool> evaluate(Evaluator &evaluator, SourceFile *SF) const;
19731971

19741972
public:
19751973
// Separate caching.

include/swift/AST/TypeCheckerTypeIDZone.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ SWIFT_REQUEST(TypeChecker, HasDefaultInitRequest,
211211
SWIFT_REQUEST(TypeChecker, SynthesizeDefaultInitRequest,
212212
ConstructorDecl *(NominalTypeDecl *), Cached, NoLocationInfo)
213213
SWIFT_REQUEST(TypeChecker, TypeCheckSourceFileRequest,
214-
bool(SouceFile *, unsigned), SeparatelyCached, NoLocationInfo)
214+
bool(SouceFile *), SeparatelyCached, NoLocationInfo)
215215
SWIFT_REQUEST(TypeChecker, TypeWitnessRequest,
216216
TypeWitnessAndDecl(NormalProtocolConformance *,
217217
AssociatedTypeDecl *),

include/swift/Subsystems.h

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,7 @@ namespace swift {
137137

138138
/// Once parsing is complete, this walks the AST to resolve imports, record
139139
/// operators, and do other top-level validation.
140-
///
141-
/// \param StartElem Where to start for incremental name binding in the main
142-
/// source file.
143-
void performNameBinding(SourceFile &SF, unsigned StartElem = 0);
140+
void performNameBinding(SourceFile &SF);
144141

145142
/// Once type-checking is complete, this instruments code with calls to an
146143
/// intrinsic that record the expected values of local variables so they can
@@ -171,10 +168,7 @@ namespace swift {
171168

172169
/// Once parsing and name-binding are complete, this walks the AST to resolve
173170
/// types and diagnose problems therein.
174-
///
175-
/// \param StartElem Where to start for incremental type-checking in the main
176-
/// source file.
177-
void performTypeChecking(SourceFile &SF, unsigned StartElem = 0);
171+
void performTypeChecking(SourceFile &SF);
178172

179173
/// Now that we have type-checked an entire module, perform any type
180174
/// checking that requires the full module, e.g., Objective-C method

lib/Sema/NameBinding.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ static void insertPrecedenceGroupDecl(NameBinder &binder, SourceFile &SF,
397397
/// UnresolvedDeclRefExpr nodes for unresolved value names, and we may have
398398
/// unresolved type names as well. This handles import directives and forward
399399
/// references.
400-
void swift::performNameBinding(SourceFile &SF, unsigned StartElem) {
400+
void swift::performNameBinding(SourceFile &SF) {
401401
FrontendStatsTracer tracer(SF.getASTContext().Stats, "Name binding");
402402

403403
// Make sure we skip adding the standard library imports if the
@@ -417,7 +417,7 @@ void swift::performNameBinding(SourceFile &SF, unsigned StartElem) {
417417

418418
// Do a prepass over the declarations to find and load the imported modules
419419
// and map operator decls.
420-
for (auto D : SF.getTopLevelDecls().slice(StartElem)) {
420+
for (auto D : SF.getTopLevelDecls()) {
421421
if (auto *ID = dyn_cast<ImportDecl>(D)) {
422422
Binder.addImport(ImportedModules, ID);
423423
} else if (auto *OD = dyn_cast<PrefixOperatorDecl>(D)) {

lib/Sema/TypeCheckAvailability.cpp

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -614,14 +614,8 @@ class TypeRefinementContextBuilder : private ASTWalker {
614614

615615
} // end anonymous namespace
616616

617-
void TypeChecker::buildTypeRefinementContextHierarchy(SourceFile &SF,
618-
unsigned StartElem) {
617+
void TypeChecker::buildTypeRefinementContextHierarchy(SourceFile &SF) {
619618
TypeRefinementContext *RootTRC = SF.getTypeRefinementContext();
620-
621-
// If we are not starting at the beginning of the source file, we had better
622-
// already have a root type refinement context.
623-
assert(StartElem == 0 || RootTRC);
624-
625619
ASTContext &Context = SF.getASTContext();
626620

627621
if (!RootTRC) {
@@ -636,7 +630,7 @@ void TypeChecker::buildTypeRefinementContextHierarchy(SourceFile &SF,
636630
// Build refinement contexts, if necessary, for all declarations starting
637631
// with StartElem.
638632
TypeRefinementContextBuilder Builder(RootTRC, Context);
639-
for (auto D : SF.getTopLevelDecls().slice(StartElem)) {
633+
for (auto D : SF.getTopLevelDecls()) {
640634
Builder.build(D);
641635
}
642636
}
@@ -645,7 +639,7 @@ TypeRefinementContext *
645639
TypeChecker::getOrBuildTypeRefinementContext(SourceFile *SF) {
646640
TypeRefinementContext *TRC = SF->getTypeRefinementContext();
647641
if (!TRC) {
648-
buildTypeRefinementContextHierarchy(*SF, 0);
642+
buildTypeRefinementContextHierarchy(*SF);
649643
TRC = SF->getTypeRefinementContext();
650644
}
651645

lib/Sema/TypeCheckREPL.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -462,17 +462,17 @@ Identifier REPLChecker::getNextResponseVariableName(DeclContext *DC) {
462462
/// processREPLTopLevel - This is called after we've parsed and typechecked some
463463
/// new decls at the top level. We inject code to print out expressions and
464464
/// pattern bindings the are evaluated.
465-
void TypeChecker::processREPLTopLevel(SourceFile &SF, unsigned FirstDecl) {
465+
void TypeChecker::processREPLTopLevel(SourceFile &SF) {
466466
// Walk over all decls in the file to find the next available closure
467467
// discriminator.
468468
DiscriminatorFinder DF;
469469
for (Decl *D : SF.getTopLevelDecls())
470470
D->walk(DF);
471471

472-
// Move new declarations out.
473-
std::vector<Decl *> NewDecls(SF.getTopLevelDecls().begin()+FirstDecl,
472+
// Move the new declarations out of the source file.
473+
std::vector<Decl *> NewDecls(SF.getTopLevelDecls().begin(),
474474
SF.getTopLevelDecls().end());
475-
SF.truncateTopLevelDecls(FirstDecl);
475+
SF.truncateTopLevelDecls(0);
476476

477477
REPLChecker RC(SF, DF);
478478

lib/Sema/TypeChecker.cpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -323,15 +323,13 @@ static void typeCheckFunctionsAndExternalDecls(SourceFile &SF, TypeChecker &TC)
323323
TC.definedFunctions.clear();
324324
}
325325

326-
void swift::performTypeChecking(SourceFile &SF, unsigned StartElem) {
326+
void swift::performTypeChecking(SourceFile &SF) {
327327
return (void)evaluateOrDefault(SF.getASTContext().evaluator,
328-
TypeCheckSourceFileRequest{&SF, StartElem},
329-
false);
328+
TypeCheckSourceFileRequest{&SF}, false);
330329
}
331330

332331
llvm::Expected<bool>
333-
TypeCheckSourceFileRequest::evaluate(Evaluator &eval,
334-
SourceFile *SF, unsigned StartElem) const {
332+
TypeCheckSourceFileRequest::evaluate(Evaluator &eval, SourceFile *SF) const {
335333
assert(SF && "Source file cannot be null!");
336334
assert(SF->ASTStage != SourceFile::TypeChecked &&
337335
"Should not be re-typechecking this file!");
@@ -352,7 +350,7 @@ TypeCheckSourceFileRequest::evaluate(Evaluator &eval,
352350

353351
// Make sure that name binding has been completed before doing any type
354352
// checking.
355-
performNameBinding(*SF, StartElem);
353+
performNameBinding(*SF);
356354

357355
// Could build scope maps here because the AST is stable now.
358356

@@ -369,7 +367,7 @@ TypeCheckSourceFileRequest::evaluate(Evaluator &eval,
369367
if (!Ctx.LangOpts.DisableAvailabilityChecking) {
370368
// Build the type refinement hierarchy for the primary
371369
// file before type checking.
372-
TypeChecker::buildTypeRefinementContextHierarchy(*SF, StartElem);
370+
TypeChecker::buildTypeRefinementContextHierarchy(*SF);
373371
}
374372

375373
// Resolve extensions. This has to occur first during type checking,
@@ -378,7 +376,7 @@ TypeCheckSourceFileRequest::evaluate(Evaluator &eval,
378376
::bindExtensions(*SF);
379377

380378
// Type check the top-level elements of the source file.
381-
for (auto D : SF->getTopLevelDecls().slice(StartElem)) {
379+
for (auto D : SF->getTopLevelDecls()) {
382380
if (auto *TLCD = dyn_cast<TopLevelCodeDecl>(D)) {
383381
// Immediately perform global name-binding etc.
384382
TypeChecker::typeCheckTopLevelCodeDecl(TLCD);
@@ -391,7 +389,7 @@ TypeCheckSourceFileRequest::evaluate(Evaluator &eval,
391389
// If we're in REPL mode, inject temporary result variables and other stuff
392390
// that the REPL needs to synthesize.
393391
if (SF->Kind == SourceFileKind::REPL && !Ctx.hadError())
394-
TypeChecker::processREPLTopLevel(*SF, StartElem);
392+
TypeChecker::processREPLTopLevel(*SF);
395393

396394
typeCheckFunctionsAndExternalDecls(*SF, TC);
397395
}

lib/Sema/TypeChecker.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,7 @@ class TypeChecker final {
680680

681681
static void typeCheckTopLevelCodeDecl(TopLevelCodeDecl *TLCD);
682682

683-
static void processREPLTopLevel(SourceFile &SF, unsigned StartElem);
683+
static void processREPLTopLevel(SourceFile &SF);
684684

685685
static void typeCheckDecl(Decl *D);
686686

@@ -1376,11 +1376,7 @@ class TypeChecker final {
13761376
const TypeRefinementContext **MostRefined=nullptr);
13771377

13781378
/// Walk the AST to build the hierarchy of TypeRefinementContexts
1379-
///
1380-
/// \param StartElem Where to start for incremental building of refinement
1381-
/// contexts
1382-
static void buildTypeRefinementContextHierarchy(SourceFile &SF,
1383-
unsigned StartElem);
1379+
static void buildTypeRefinementContextHierarchy(SourceFile &SF);
13841380

13851381
/// Build the hierarchy of TypeRefinementContexts for the entire
13861382
/// source file, if it has not already been built. Returns the root

0 commit comments

Comments
 (0)