@@ -483,9 +483,7 @@ class NodeAdder
483483 ASTScopeImpl *visitTopLevelCodeDecl (TopLevelCodeDecl *d,
484484 ASTScopeImpl *p,
485485 ScopeCreator &scopeCreator) {
486- ASTScopeAssert (endLoc.has_value (), " TopLevelCodeDecl in wrong place?" );
487- return scopeCreator.constructExpandAndInsert <TopLevelCodeScope>(
488- p, d, *endLoc);
486+ return scopeCreator.constructExpandAndInsert <TopLevelCodeScope>(p, d);
489487 }
490488
491489#pragma mark special-case creation
@@ -800,10 +798,10 @@ CREATES_NEW_INSERTION_POINT(GuardStmtScope)
800798CREATES_NEW_INSERTION_POINT(PatternEntryDeclScope)
801799CREATES_NEW_INSERTION_POINT(GenericTypeOrExtensionScope)
802800CREATES_NEW_INSERTION_POINT(BraceStmtScope)
803- CREATES_NEW_INSERTION_POINT(TopLevelCodeScope)
804801CREATES_NEW_INSERTION_POINT(ConditionalClausePatternUseScope)
805802CREATES_NEW_INSERTION_POINT(ABIAttributeScope)
806803
804+ NO_NEW_INSERTION_POINT(TopLevelCodeScope)
807805NO_NEW_INSERTION_POINT(FunctionBodyScope)
808806NO_NEW_INSERTION_POINT(AbstractFunctionDeclScope)
809807NO_NEW_INSERTION_POINT(CustomAttributeScope)
@@ -1017,19 +1015,6 @@ BraceStmtScope::expandAScopeThatCreatesANewInsertionPoint(
10171015 " For top-level code decls, need the scope under, say a guard statement." };
10181016}
10191017
1020- AnnotatedInsertionPoint
1021- TopLevelCodeScope::expandAScopeThatCreatesANewInsertionPoint (ScopeCreator &
1022- scopeCreator) {
1023-
1024- auto *body =
1025- scopeCreator
1026- .addToScopeTreeAndReturnInsertionPoint (decl->getBody (), this , endLoc);
1027-
1028- return {body, " So next top level code scope and put its decls in its body "
1029- " under a guard statement scope (etc) from the last top level "
1030- " code scope" };
1031- }
1032-
10331018AnnotatedInsertionPoint
10341019ABIAttributeScope::expandAScopeThatCreatesANewInsertionPoint (
10351020 ScopeCreator &scopeCreator) {
@@ -1294,6 +1279,12 @@ void CustomAttributeScope::
12941279 }
12951280}
12961281
1282+ void TopLevelCodeScope::expandAScopeThatDoesNotCreateANewInsertionPoint (
1283+ ScopeCreator &scopeCreator) {
1284+ insertionPoint = scopeCreator.addToScopeTreeAndReturnInsertionPoint (decl->getBody (), this ,
1285+ std::nullopt );
1286+ }
1287+
12971288#pragma mark expandScope
12981289
12991290ASTScopeImpl *GenericTypeOrExtensionWholePortion::expandScope (
0 commit comments