Skip to content

Commit c4314eb

Browse files
committed
ASTScope: SourceFile scopes are always current
1 parent f9812e8 commit c4314eb

File tree

2 files changed

+1
-17
lines changed

2 files changed

+1
-17
lines changed

include/swift/AST/ASTScope.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -530,12 +530,6 @@ class ASTSourceFileScope final : public ASTScopeImpl {
530530
ScopeCreator *const scopeCreator;
531531
ASTScopeImpl *insertionPoint;
532532

533-
/// The number of \c Decls in the \c SourceFile that were already seen.
534-
/// Since parsing can be interleaved with type-checking, on every
535-
/// lookup, look at creating scopes for any \c Decls beyond this number.
536-
/// TODO: Unify with numberOfChildrenWhenLastExpanded
537-
size_t numberOfDeclsAlreadySeen = 0;
538-
539533
ASTSourceFileScope(SourceFile *SF, ScopeCreator *scopeCreator);
540534

541535
std::string getClassName() const override;
@@ -560,8 +554,6 @@ class ASTSourceFileScope final : public ASTScopeImpl {
560554

561555
protected:
562556
ASTScopeImpl *expandSpecifically(ScopeCreator &scopeCreator) override;
563-
bool isCurrentIfWasExpanded() const override;
564-
void beCurrent() override;
565557
bool doesExpansionOnlyAddNewDeclsAtEnd() const override;
566558

567559
ScopeCreator &getScopeCreator() override;

lib/AST/ASTScopeCreation.cpp

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1056,8 +1056,7 @@ ASTSourceFileScope::expandAScopeThatCreatesANewInsertionPoint(
10561056
ASTScopeAssert(SF, "Must already have a SourceFile.");
10571057
ArrayRef<Decl *> decls = SF->getTopLevelDecls();
10581058
// Assume that decls are only added at the end, in source order
1059-
ArrayRef<Decl *> newDecls = decls.slice(numberOfDeclsAlreadySeen);
1060-
std::vector<ASTNode> newNodes(newDecls.begin(), newDecls.end());
1059+
std::vector<ASTNode> newNodes(decls.begin(), decls.end());
10611060
insertionPoint =
10621061
scopeCreator.addSiblingsToScopeTree(insertionPoint, this, newNodes);
10631062
// Too slow to perform all the time:
@@ -1688,13 +1687,6 @@ bool ASTScopeImpl::isCurrent() const {
16881687
void ASTScopeImpl::beCurrent() {}
16891688
bool ASTScopeImpl::isCurrentIfWasExpanded() const { return true; }
16901689

1691-
void ASTSourceFileScope::beCurrent() {
1692-
numberOfDeclsAlreadySeen = SF->getTopLevelDecls().size();
1693-
}
1694-
bool ASTSourceFileScope::isCurrentIfWasExpanded() const {
1695-
return SF->getTopLevelDecls().size() == numberOfDeclsAlreadySeen;
1696-
}
1697-
16981690
#pragma mark getParentOfASTAncestorScopesToBeRescued
16991691
NullablePtr<ASTScopeImpl>
17001692
ASTScopeImpl::getParentOfASTAncestorScopesToBeRescued() {

0 commit comments

Comments
 (0)