@@ -218,7 +218,7 @@ class ScopeCreator final {
218
218
ASTScopeImpl *const organicInsertionPoint,
219
219
ArrayRef<ASTNode> nodesOrDeclsToAdd) {
220
220
auto *ip = insertionPoint;
221
- for (auto nd : sortBySourceRange ( cull ( nodesOrDeclsToAdd)) ) {
221
+ for (auto nd : nodesOrDeclsToAdd) {
222
222
auto *const newIP =
223
223
addToScopeTreeAndReturnInsertionPoint (nd, ip).getPtrOr (ip);
224
224
ip = newIP;
@@ -419,9 +419,6 @@ class ScopeCreator final {
419
419
void addChildrenForKnownAttributes (ValueDecl *decl,
420
420
ASTScopeImpl *parent);
421
421
422
- public:
423
-
424
- private:
425
422
// / Remove VarDecls because we'll find them when we expand the
426
423
// / PatternBindingDecls. Remove EnunCases
427
424
// / because they overlap EnumElements and AST includes the elements in the
@@ -463,7 +460,6 @@ class ScopeCreator final {
463
460
return -1 == signum;
464
461
}
465
462
466
- public:
467
463
SWIFT_DEBUG_DUMP { print (llvm::errs ()); }
468
464
469
465
void print (raw_ostream &out) const {
@@ -950,7 +946,9 @@ ASTSourceFileScope::expandAScopeThatCreatesANewInsertionPoint(
950
946
// Assume that decls are only added at the end, in source order
951
947
std::vector<ASTNode> newNodes (decls.begin (), decls.end ());
952
948
insertionPoint =
953
- scopeCreator.addSiblingsToScopeTree (insertionPoint, this , newNodes);
949
+ scopeCreator.addSiblingsToScopeTree (insertionPoint, this ,
950
+ scopeCreator.sortBySourceRange (
951
+ scopeCreator.cull (newNodes)));
954
952
// Too slow to perform all the time:
955
953
// ASTScopeAssert(scopeCreator->containsAllDeclContextsFromAST(),
956
954
// "ASTScope tree missed some DeclContexts or made some up");
@@ -1068,7 +1066,10 @@ BraceStmtScope::expandAScopeThatCreatesANewInsertionPoint(
1068
1066
// TODO: remove the sort after fixing parser to create brace statement
1069
1067
// elements in source order
1070
1068
auto *insertionPoint =
1071
- scopeCreator.addSiblingsToScopeTree (this , this , stmt->getElements ());
1069
+ scopeCreator.addSiblingsToScopeTree (this , this ,
1070
+ scopeCreator.sortBySourceRange (
1071
+ scopeCreator.cull (
1072
+ stmt->getElements ())));
1072
1073
if (auto *s = scopeCreator.getASTContext ().Stats )
1073
1074
++s->getFrontendCounters ().NumBraceStmtASTScopeExpansions ;
1074
1075
return {
@@ -1414,6 +1415,7 @@ void GenericTypeOrExtensionScope::expandBody(ScopeCreator &) {}
1414
1415
1415
1416
void IterableTypeScope::expandBody (ScopeCreator &scopeCreator) {
1416
1417
auto nodes = asNodeVector (getIterableDeclContext ().get ()->getMembers ());
1418
+ nodes = scopeCreator.sortBySourceRange (scopeCreator.cull (nodes));
1417
1419
scopeCreator.addSiblingsToScopeTree (this , this , nodes);
1418
1420
if (auto *s = scopeCreator.getASTContext ().Stats )
1419
1421
++s->getFrontendCounters ().NumIterableTypeBodyASTScopeExpansions ;
0 commit comments