@@ -417,10 +417,6 @@ class ASTScopeImpl {
417
417
static llvm::SmallVector<LabeledStmt *, 4 >
418
418
lookupLabeledStmts (SourceFile *sourceFile, SourceLoc loc);
419
419
420
- static Optional<bool >
421
- computeIsCascadingUse (ArrayRef<const ASTScopeImpl *> history,
422
- Optional<bool > initialIsCascadingUse);
423
-
424
420
static std::pair<CaseStmt *, CaseStmt *>
425
421
lookupFallthroughSourceAndDest (SourceFile *sourceFile, SourceLoc loc);
426
422
@@ -448,7 +444,6 @@ class ASTScopeImpl {
448
444
// / The main (recursive) lookup function:
449
445
// / Tell DeclConsumer about all names found in this scope and if not done,
450
446
// / recurse for enclosing scopes. Stop lookup if about to look in limit.
451
- // / Return final value for isCascadingUse
452
447
// /
453
448
// / If the lookup depends on implicit self, selfDC is its context.
454
449
// / (Names in extensions never depend on self.)
@@ -508,9 +503,6 @@ class ASTScopeImpl {
508
503
509
504
#pragma mark - - lookup- local bindings
510
505
protected:
511
- virtual Optional<bool >
512
- resolveIsCascadingUseForThisScope (Optional<bool >) const ;
513
-
514
506
// A local binding is a basically a local variable defined in that very scope
515
507
// It is not an instance variable or inherited type.
516
508
@@ -611,11 +603,11 @@ class Portion {
611
603
virtual ASTScopeImpl *expandScope (GenericTypeOrExtensionScope *,
612
604
ScopeCreator &) const = 0;
613
605
606
+ // / \Returns \c true if this lookup is done looking for results, else \c false.
614
607
virtual SourceRange
615
608
getChildlessSourceRangeOf (const GenericTypeOrExtensionScope *scope,
616
609
bool omitAssertions) const = 0 ;
617
610
618
- // / Returns isDone and isCascadingUse
619
611
virtual bool lookupMembersOf (const GenericTypeOrExtensionScope *scope,
620
612
ArrayRef<const ASTScopeImpl *>,
621
613
ASTScopeImpl::DeclConsumer consumer) const ;
@@ -780,10 +772,6 @@ class GenericTypeOrExtensionScope : public ASTScopeImpl {
780
772
virtual bool doesDeclHaveABody () const ;
781
773
const char *portionName () const { return portion->portionName ; }
782
774
783
- protected:
784
- Optional<bool > resolveIsCascadingUseForThisScope (
785
- Optional<bool > isCascadingUse) const override ;
786
-
787
775
public:
788
776
// Only for DeclScope, not BodyScope
789
777
// Returns the where clause scope, or the parent if none
@@ -969,8 +957,7 @@ class GenericParamScope final : public ASTScopeImpl {
969
957
protected:
970
958
bool lookupLocalsOrMembers (ArrayRef<const ASTScopeImpl *>,
971
959
DeclConsumer) const override ;
972
- Optional<bool >
973
- resolveIsCascadingUseForThisScope (Optional<bool >) const override ;
960
+ bool doesContextMatchStartingContext (const DeclContext *) const override ;
974
961
};
975
962
976
963
// / Concrete class for a function/initializer/deinitializer
@@ -1014,9 +1001,6 @@ class AbstractFunctionDeclScope final : public ASTScopeImpl {
1014
1001
1015
1002
protected:
1016
1003
NullablePtr<const GenericParamList> genericParams () const override ;
1017
-
1018
- Optional<bool >
1019
- resolveIsCascadingUseForThisScope (Optional<bool >) const override ;
1020
1004
};
1021
1005
1022
1006
// / The parameters for an abstract function (init/func/deinit)., subscript, and
@@ -1087,8 +1071,6 @@ class AbstractFunctionBodyScope : public ASTScopeImpl {
1087
1071
protected:
1088
1072
bool lookupLocalsOrMembers (ArrayRef<const ASTScopeImpl *>,
1089
1073
DeclConsumer) const override ;
1090
- Optional<bool >
1091
- resolveIsCascadingUseForThisScope (Optional<bool >) const override ;
1092
1074
1093
1075
public:
1094
1076
NullablePtr<ASTScopeImpl> insertionPointForDeferredExpansion () override ;
@@ -1123,10 +1105,6 @@ class DefaultArgumentInitializerScope final : public ASTScopeImpl {
1123
1105
virtual NullablePtr<DeclContext> getDeclContext () const override ;
1124
1106
virtual NullablePtr<Decl> getDeclIfAny () const override { return decl; }
1125
1107
Decl *getDecl () const { return decl; }
1126
-
1127
- protected:
1128
- Optional<bool >
1129
- resolveIsCascadingUseForThisScope (Optional<bool >) const override ;
1130
1108
};
1131
1109
1132
1110
// / Consider:
@@ -1274,9 +1252,6 @@ class PatternEntryInitializerScope final : public AbstractPatternEntryScope {
1274
1252
protected:
1275
1253
bool lookupLocalsOrMembers (ArrayRef<const ASTScopeImpl *>,
1276
1254
DeclConsumer) const override ;
1277
-
1278
- Optional<bool >
1279
- resolveIsCascadingUseForThisScope (Optional<bool >) const override ;
1280
1255
};
1281
1256
1282
1257
// / The scope introduced by a conditional clause in an if/guard/while
@@ -1392,6 +1367,42 @@ class ClosureParametersScope final : public ASTScopeImpl {
1392
1367
NullablePtr<Expr> getExprIfAny () const override { return closureExpr; }
1393
1368
Expr *getExpr () const { return closureExpr; }
1394
1369
NullablePtr<const void > getReferrent () const override ;
1370
+ };
1371
+
1372
+ // / For a closure with named parameters, this scope does the local bindings.
1373
+ // / Absent if no "in".
1374
+ class ClosureParametersScope final : public AbstractClosureScope {
1375
+ public:
1376
+ ClosureParametersScope (ClosureExpr *closureExpr,
1377
+ NullablePtr<CaptureListExpr> captureList)
1378
+ : AbstractClosureScope(closureExpr, captureList) {}
1379
+ virtual ~ClosureParametersScope () {}
1380
+
1381
+ std::string getClassName () const override ;
1382
+ SourceRange
1383
+ getSourceRangeOfThisASTNode (bool omitAssertions = false ) const override ;
1384
+
1385
+ // / Since explicit captures of \c self by closures enable the use of implicit
1386
+ // / \c self, we need to make sure that the appropriate \c self is used as the
1387
+ // / base decl for these uses (otherwise, the capture would be marked as
1388
+ // / unused. \c ClosureParametersScope::capturedSelfDC() checks if we have such
1389
+ // / a capture of self.
1390
+ NullablePtr<DeclContext> capturedSelfDC () const override ;
1391
+
1392
+ protected:
1393
+ ASTScopeImpl *expandSpecifically (ScopeCreator &) override ;
1394
+ bool lookupLocalsOrMembers (ArrayRef<const ASTScopeImpl *>,
1395
+ DeclConsumer) const override ;
1396
+ };
1397
+
1398
+ // The body encompasses the code in the closure; the part after the "in" if
1399
+ // there is an "in"
1400
+ class ClosureBodyScope final : public AbstractClosureScope {
1401
+ public:
1402
+ ClosureBodyScope (ClosureExpr *closureExpr,
1403
+ NullablePtr<CaptureListExpr> captureList)
1404
+ : AbstractClosureScope(closureExpr, captureList) {}
1405
+ virtual ~ClosureBodyScope () {}
1395
1406
1396
1407
protected:
1397
1408
ASTScopeImpl *expandSpecifically (ScopeCreator &scopeCreator) override ;
@@ -1402,8 +1413,10 @@ class ClosureParametersScope final : public ASTScopeImpl {
1402
1413
protected:
1403
1414
bool lookupLocalsOrMembers (ArrayRef<const ASTScopeImpl *>,
1404
1415
DeclConsumer) const override ;
1405
- Optional<bool > resolveIsCascadingUseForThisScope (
1406
- Optional<bool > isCascadingUse) const override ;
1416
+ public:
1417
+ std::string getClassName () const override ;
1418
+ SourceRange
1419
+ getSourceRangeOfThisASTNode (bool omitAssertions = false ) const override ;
1407
1420
};
1408
1421
1409
1422
class TopLevelCodeScope final : public ASTScopeImpl {
0 commit comments