|
23 | 23 | #include "swift/AST/Initializer.h"
|
24 | 24 | #include "swift/AST/LazyResolver.h"
|
25 | 25 | #include "swift/AST/Module.h"
|
| 26 | +#include "swift/AST/NameLookupRequests.h" |
26 | 27 | #include "swift/AST/ParameterList.h"
|
27 | 28 | #include "swift/AST/Pattern.h"
|
28 | 29 | #include "swift/AST/SourceFile.h"
|
@@ -340,7 +341,8 @@ class ScopeCreator final {
|
340 | 341 | if (auto *ip = child->insertionPointForDeferredExpansion().getPtrOrNull())
|
341 | 342 | return ip;
|
342 | 343 | }
|
343 |
| - ASTScopeImpl *insertionPoint = child->expandAndBeCurrent(*this); |
| 344 | + ASTScopeImpl *insertionPoint = |
| 345 | + child->expandAndBeCurrentDetectingRecursion(*this); |
344 | 346 | ASTScopeAssert(child->verifyThatThisNodeComeAfterItsPriorSibling(),
|
345 | 347 | "Ensure search will work");
|
346 | 348 | return insertionPoint;
|
@@ -1083,6 +1085,18 @@ void ASTScopeImpl::disownDescendants(ScopeCreator &scopeCreator) {
|
1083 | 1085 |
|
1084 | 1086 | #pragma mark implementations of expansion
|
1085 | 1087 |
|
| 1088 | +ASTScopeImpl * |
| 1089 | +ASTScopeImpl::expandAndBeCurrentDetectingRecursion(ScopeCreator &scopeCreator) { |
| 1090 | + return evaluateOrDefault(scopeCreator.getASTContext().evaluator, |
| 1091 | + ExpandASTScopeRequest{this, &scopeCreator}, nullptr); |
| 1092 | +} |
| 1093 | + |
| 1094 | +llvm::Expected<ASTScopeImpl *> |
| 1095 | +ExpandASTScopeRequest::evaluate(Evaluator &evaluator, ASTScopeImpl *parent, |
| 1096 | + ScopeCreator *scopeCreator) const { |
| 1097 | + return parent->expandAndBeCurrent(*scopeCreator); |
| 1098 | +} |
| 1099 | + |
1086 | 1100 | ASTScopeImpl *ASTScopeImpl::expandAndBeCurrent(ScopeCreator &scopeCreator) {
|
1087 | 1101 | auto *insertionPoint = expandSpecifically(scopeCreator);
|
1088 | 1102 | if (scopeCreator.shouldBeLazy()) {
|
@@ -1755,7 +1769,7 @@ void ASTScopeImpl::reexpand(ScopeCreator &scopeCreator) {
|
1755 | 1769 | disownDescendants(scopeCreator);
|
1756 | 1770 | // If the expansion recurses back into the tree for lookup, the ASTAncestor
|
1757 | 1771 | // scopes will have already been rescued and won't be found!
|
1758 |
| - expandAndBeCurrent(scopeCreator); |
| 1772 | + expandAndBeCurrentDetectingRecursion(scopeCreator); |
1759 | 1773 | replaceASTAncestorScopes(astAncestorScopes);
|
1760 | 1774 | }
|
1761 | 1775 |
|
@@ -2073,3 +2087,8 @@ ScopeCreator::findLocalizableDeclContextsInAST() const {
|
2073 | 2087 | bool ASTSourceFileScope::crossCheckWithAST() {
|
2074 | 2088 | return scopeCreator->containsAllDeclContextsFromAST();
|
2075 | 2089 | }
|
| 2090 | + |
| 2091 | +void swift::simple_display(llvm::raw_ostream &out, |
| 2092 | + const ast_scope::ScopeCreator *scopeCreator) { |
| 2093 | + scopeCreator->print(out); |
| 2094 | +} |
0 commit comments