30
30
31
31
#include " swift/AST/ASTNode.h"
32
32
#include " swift/AST/NameLookup.h" // for DeclVisibilityKind
33
- #include " swift/AST/SimpleRequest.h"
34
33
#include " swift/Basic/Compiler.h"
35
34
#include " swift/Basic/LLVM.h"
36
35
#include " swift/Basic/NullablePtr.h"
@@ -89,14 +88,6 @@ struct AnnotatedInsertionPoint {
89
88
ASTScopeImpl *insertionPoint;
90
89
const char *explanation;
91
90
};
92
- } // namespace ast_scope
93
-
94
- namespace ast_scope {
95
-
96
- void simple_display (llvm::raw_ostream &out, const ASTScopeImpl *);
97
- void simple_display (llvm::raw_ostream &out, const ScopeCreator *);
98
-
99
- SourceLoc extractNearestSourceLoc (std::tuple<ASTScopeImpl *, ScopeCreator *>);
100
91
101
92
#pragma mark the root ASTScopeImpl class
102
93
@@ -342,11 +333,6 @@ class ASTScopeImpl {
342
333
public:
343
334
// / expandScope me, sending deferred nodes to my descendants.
344
335
// / Return the scope into which to place subsequent decls
345
- ASTScopeImpl *expandAndBeCurrentDetectingRecursion (ScopeCreator &);
346
-
347
- // / Expand or reexpand the scope if unexpanded or if not current.
348
- // / There are several places in the compiler that mutate the AST after the
349
- // / fact, above and beyond adding Decls to the SourceFile.
350
336
ASTScopeImpl *expandAndBeCurrent (ScopeCreator &);
351
337
352
338
unsigned getASTAncestorScopeCount () const { return astAncestorScopeCount; }
@@ -358,12 +344,6 @@ class ASTScopeImpl {
358
344
void setWasExpanded () { wasExpanded = true ; }
359
345
virtual ASTScopeImpl *expandSpecifically (ScopeCreator &) = 0;
360
346
virtual void beCurrent ();
361
- virtual bool doesExpansionOnlyAddNewDeclsAtEnd () const ;
362
-
363
- public:
364
- bool isExpansionNeeded (const ScopeCreator &) const ;
365
-
366
- protected:
367
347
bool isCurrent () const ;
368
348
virtual bool isCurrentIfWasExpanded () const ;
369
349
@@ -394,7 +374,16 @@ class ASTScopeImpl {
394
374
395
375
bool isATypeDeclScope () const ;
396
376
377
+ // / There are several places in the compiler that mutate the AST after the
378
+ // / fact, above and beyond adding Decls to the SourceFile. These are
379
+ // / documented in: rdar://53018839, rdar://53027266, rdar://53027733,
380
+ // / rdar://53028050
381
+ // / Return true if did reexpand
382
+ bool reexpandIfObsolete (ScopeCreator &);
383
+
397
384
private:
385
+ void reexpand (ScopeCreator &);
386
+
398
387
virtual ScopeCreator &getScopeCreator ();
399
388
400
389
#pragma mark - - creation queries
@@ -544,8 +533,8 @@ class ASTSourceFileScope final : public ASTScopeImpl {
544
533
// / The number of \c Decls in the \c SourceFile that were already seen.
545
534
// / Since parsing can be interleaved with type-checking, on every
546
535
// / lookup, look at creating scopes for any \c Decls beyond this number.
547
- // / TODO: Unify with numberOfChildrenWhenLastExpanded
548
- size_t numberOfDeclsAlreadySeen = 0 ;
536
+ // / rdar://55562483 Unify with numberOfChildrenWhenLastExpanded
537
+ int numberOfDeclsAlreadySeen = 0 ;
549
538
550
539
ASTSourceFileScope (SourceFile *SF, ScopeCreator *scopeCreator);
551
540
@@ -559,6 +548,7 @@ class ASTSourceFileScope final : public ASTScopeImpl {
559
548
public:
560
549
NullablePtr<DeclContext> getDeclContext () const override ;
561
550
551
+ void addNewDeclsToScopeTree ();
562
552
void buildFullyExpandedTree ();
563
553
void
564
554
buildEnoughOfTreeForTopLevelExpressionsButDontRequestGenericsOrExtendedNominals ();
@@ -569,15 +559,11 @@ class ASTSourceFileScope final : public ASTScopeImpl {
569
559
570
560
protected:
571
561
ASTScopeImpl *expandSpecifically (ScopeCreator &scopeCreator) override ;
572
- bool isCurrentIfWasExpanded () const override ;
573
- void beCurrent () override ;
574
- bool doesExpansionOnlyAddNewDeclsAtEnd () const override ;
575
562
576
563
ScopeCreator &getScopeCreator () override ;
577
564
578
565
private:
579
- AnnotatedInsertionPoint
580
- expandAScopeThatCreatesANewInsertionPoint (ScopeCreator &);
566
+ void expandAScopeThatDoesNotCreateANewInsertionPoint (ScopeCreator &);
581
567
};
582
568
583
569
class Portion {
@@ -1162,6 +1148,7 @@ class AttachedPropertyWrapperScope final : public ASTScopeImpl {
1162
1148
// / false positives, that that doesn't hurt anything. However, the result of
1163
1149
// / the conservative source range computation doesn't seem to be stable. So
1164
1150
// / keep the original here, and use it for source range queries.
1151
+ // / rdar://55263708
1165
1152
1166
1153
const SourceRange sourceRangeWhenCreated;
1167
1154
@@ -1264,6 +1251,7 @@ class PatternEntryDeclScope final : public AbstractPatternEntryScope {
1264
1251
};
1265
1252
1266
1253
class PatternEntryInitializerScope final : public AbstractPatternEntryScope {
1254
+ // Should be able to remove this when rdar://53921703 is accomplished.
1267
1255
Expr *initAsWrittenWhenCreated;
1268
1256
1269
1257
public:
0 commit comments