Skip to content

Commit 7d50b98

Browse files
committed
ASTScope: IterableDeclContext bodies are always current
1 parent b7bd4fb commit 7d50b98

File tree

2 files changed

+0
-81
lines changed

2 files changed

+0
-81
lines changed

include/swift/AST/ASTScope.h

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -609,8 +609,6 @@ class Portion {
609609
virtual const Decl *
610610
getReferrentOfScope(const GenericTypeOrExtensionScope *s) const;
611611

612-
virtual void beCurrent(IterableTypeScope *) const = 0;
613-
virtual bool isCurrentIfWasExpanded(const IterableTypeScope *) const = 0;
614612
virtual NullablePtr<ASTScopeImpl>
615613
insertionPointForDeferredExpansion(IterableTypeScope *) const = 0;
616614
virtual SourceRange
@@ -636,19 +634,6 @@ class Portion {
636634
const Decl *
637635
getReferrentOfScope(const GenericTypeOrExtensionScope *s) const override;
638636

639-
/// Make whole portion lazy to avoid circularity in lookup of generic
640-
/// parameters of extensions. When \c bindExtension is called, it needs to
641-
/// unqualifed-lookup the type being extended. That causes an \c
642-
/// ExtensionScope
643-
/// (\c GenericTypeOrExtensionWholePortion) to be built.
644-
/// The building process needs the generic parameters, but that results in a
645-
/// request for the extended nominal type of the \c ExtensionDecl, which is
646-
/// an endless recursion. Although we only need to make \c ExtensionScope
647-
/// lazy, might as well do it for all \c IterableTypeScopes.
648-
649-
void beCurrent(IterableTypeScope *) const override;
650-
bool isCurrentIfWasExpanded(const IterableTypeScope *) const override;
651-
652637
NullablePtr<ASTScopeImpl>
653638
insertionPointForDeferredExpansion(IterableTypeScope *) const override;
654639
SourceRange
@@ -682,9 +667,6 @@ class GenericTypeOrExtensionWherePortion final
682667
SourceRange getChildlessSourceRangeOf(const GenericTypeOrExtensionScope *,
683668
bool omitAssertions) const override;
684669

685-
void beCurrent(IterableTypeScope *) const override;
686-
bool isCurrentIfWasExpanded(const IterableTypeScope *) const override;
687-
688670
NullablePtr<ASTScopeImpl>
689671
insertionPointForDeferredExpansion(IterableTypeScope *) const override;
690672
SourceRange
@@ -704,8 +686,6 @@ class IterableTypeBodyPortion final
704686
SourceRange getChildlessSourceRangeOf(const GenericTypeOrExtensionScope *,
705687
bool omitAssertions) const override;
706688

707-
void beCurrent(IterableTypeScope *) const override;
708-
bool isCurrentIfWasExpanded(const IterableTypeScope *) const override;
709689
NullablePtr<ASTScopeImpl>
710690
insertionPointForDeferredExpansion(IterableTypeScope *) const override;
711691
SourceRange
@@ -796,11 +776,6 @@ class GenericTypeScope : public GenericTypeOrExtensionScope {
796776
};
797777

798778
class IterableTypeScope : public GenericTypeScope {
799-
/// Because of \c parseDelayedDecl members can get added after the tree is
800-
/// constructed, and they can be out of order. Detect this happening by
801-
/// remembering the member count.
802-
unsigned memberCount = 0;
803-
804779
public:
805780
IterableTypeScope(const Portion *p) : GenericTypeScope(p) {}
806781
virtual ~IterableTypeScope() {}
@@ -810,15 +785,7 @@ class IterableTypeScope : public GenericTypeScope {
810785
bool doesDeclHaveABody() const override;
811786
void expandBody(ScopeCreator &) override;
812787

813-
protected:
814-
void beCurrent() override;
815-
bool isCurrentIfWasExpanded() const override;
816-
817788
public:
818-
void makeWholeCurrent();
819-
bool isWholeCurrent() const;
820-
void makeBodyCurrent();
821-
bool isBodyCurrent() const;
822789
NullablePtr<ASTScopeImpl> insertionPointForDeferredExpansion() override;
823790
SourceRange sourceRangeForDeferredExpansion() const override;
824791

lib/AST/ASTScopeCreation.cpp

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -330,14 +330,6 @@ class ScopeCreator final {
330330
return nullptr;
331331
}
332332

333-
template <typename Scope, typename... Args>
334-
ASTScopeImpl *ensureUniqueThenConstructExpandAndInsert(ASTScopeImpl *parent,
335-
Args... args) {
336-
if (auto s = ifUniqueConstructExpandAndInsert<Scope>(parent, args...))
337-
return s.get();
338-
ASTScope_unreachable("Scope should have been unique");
339-
}
340-
341333
private:
342334
template <typename Scope, typename... Args>
343335
ASTScopeImpl *constructExpandAndInsert(ASTScopeImpl *parent, Args... args) {
@@ -1703,46 +1695,6 @@ bool ASTSourceFileScope::isCurrentIfWasExpanded() const {
17031695
return SF->getTopLevelDecls().size() == numberOfDeclsAlreadySeen;
17041696
}
17051697

1706-
void IterableTypeScope::beCurrent() { portion->beCurrent(this); }
1707-
bool IterableTypeScope::isCurrentIfWasExpanded() const {
1708-
return portion->isCurrentIfWasExpanded(this);
1709-
}
1710-
1711-
void GenericTypeOrExtensionWholePortion::beCurrent(IterableTypeScope *s) const {
1712-
s->makeWholeCurrent();
1713-
}
1714-
bool GenericTypeOrExtensionWholePortion::isCurrentIfWasExpanded(
1715-
const IterableTypeScope *s) const {
1716-
return s->isWholeCurrent();
1717-
}
1718-
void GenericTypeOrExtensionWherePortion::beCurrent(IterableTypeScope *) const {}
1719-
bool GenericTypeOrExtensionWherePortion::isCurrentIfWasExpanded(
1720-
const IterableTypeScope *) const {
1721-
return true;
1722-
}
1723-
void IterableTypeBodyPortion::beCurrent(IterableTypeScope *s) const {
1724-
s->makeBodyCurrent();
1725-
}
1726-
bool IterableTypeBodyPortion::isCurrentIfWasExpanded(
1727-
const IterableTypeScope *s) const {
1728-
return s->isBodyCurrent();
1729-
}
1730-
1731-
void IterableTypeScope::makeWholeCurrent() {
1732-
ASTScopeAssert(getWasExpanded(), "Should have been expanded");
1733-
}
1734-
bool IterableTypeScope::isWholeCurrent() const {
1735-
// Whole starts out unexpanded, and is lazily built but will have at least a
1736-
// body scope child
1737-
return getWasExpanded();
1738-
}
1739-
void IterableTypeScope::makeBodyCurrent() {
1740-
memberCount = getIterableDeclContext().get()->getMemberCount();
1741-
}
1742-
bool IterableTypeScope::isBodyCurrent() const {
1743-
return memberCount == getIterableDeclContext().get()->getMemberCount();
1744-
}
1745-
17461698
void AbstractFunctionBodyScope::beCurrent() {
17471699
bodyWhenLastExpanded = decl->getBody(false);
17481700
}

0 commit comments

Comments
 (0)