@@ -417,10 +417,6 @@ class ASTScopeImpl {
417417 static llvm::SmallVector<LabeledStmt *, 4 >
418418 lookupLabeledStmts (SourceFile *sourceFile, SourceLoc loc);
419419
420- static Optional<bool >
421- computeIsCascadingUse (ArrayRef<const ASTScopeImpl *> history,
422- Optional<bool > initialIsCascadingUse);
423-
424420 static std::pair<CaseStmt *, CaseStmt *>
425421 lookupFallthroughSourceAndDest (SourceFile *sourceFile, SourceLoc loc);
426422
@@ -448,7 +444,6 @@ class ASTScopeImpl {
448444 // / The main (recursive) lookup function:
449445 // / Tell DeclConsumer about all names found in this scope and if not done,
450446 // / recurse for enclosing scopes. Stop lookup if about to look in limit.
451- // / Return final value for isCascadingUse
452447 // /
453448 // / If the lookup depends on implicit self, selfDC is its context.
454449 // / (Names in extensions never depend on self.)
@@ -508,9 +503,6 @@ class ASTScopeImpl {
508503
509504#pragma mark - - lookup- local bindings
510505protected:
511- virtual Optional<bool >
512- resolveIsCascadingUseForThisScope (Optional<bool >) const ;
513-
514506 // A local binding is a basically a local variable defined in that very scope
515507 // It is not an instance variable or inherited type.
516508
@@ -611,11 +603,11 @@ class Portion {
611603 virtual ASTScopeImpl *expandScope (GenericTypeOrExtensionScope *,
612604 ScopeCreator &) const = 0;
613605
606+ // / \Returns \c true if this lookup is done looking for results, else \c false.
614607 virtual SourceRange
615608 getChildlessSourceRangeOf (const GenericTypeOrExtensionScope *scope,
616609 bool omitAssertions) const = 0 ;
617610
618- // / Returns isDone and isCascadingUse
619611 virtual bool lookupMembersOf (const GenericTypeOrExtensionScope *scope,
620612 ArrayRef<const ASTScopeImpl *>,
621613 ASTScopeImpl::DeclConsumer consumer) const ;
@@ -780,10 +772,6 @@ class GenericTypeOrExtensionScope : public ASTScopeImpl {
780772 virtual bool doesDeclHaveABody () const ;
781773 const char *portionName () const { return portion->portionName ; }
782774
783- protected:
784- Optional<bool > resolveIsCascadingUseForThisScope (
785- Optional<bool > isCascadingUse) const override ;
786-
787775public:
788776 // Only for DeclScope, not BodyScope
789777 // Returns the where clause scope, or the parent if none
@@ -969,8 +957,7 @@ class GenericParamScope final : public ASTScopeImpl {
969957protected:
970958 bool lookupLocalsOrMembers (ArrayRef<const ASTScopeImpl *>,
971959 DeclConsumer) const override ;
972- Optional<bool >
973- resolveIsCascadingUseForThisScope (Optional<bool >) const override ;
960+ bool doesContextMatchStartingContext (const DeclContext *) const override ;
974961};
975962
976963// / Concrete class for a function/initializer/deinitializer
@@ -1014,9 +1001,6 @@ class AbstractFunctionDeclScope final : public ASTScopeImpl {
10141001
10151002protected:
10161003 NullablePtr<const GenericParamList> genericParams () const override ;
1017-
1018- Optional<bool >
1019- resolveIsCascadingUseForThisScope (Optional<bool >) const override ;
10201004};
10211005
10221006// / The parameters for an abstract function (init/func/deinit)., subscript, and
@@ -1087,8 +1071,6 @@ class AbstractFunctionBodyScope : public ASTScopeImpl {
10871071protected:
10881072 bool lookupLocalsOrMembers (ArrayRef<const ASTScopeImpl *>,
10891073 DeclConsumer) const override ;
1090- Optional<bool >
1091- resolveIsCascadingUseForThisScope (Optional<bool >) const override ;
10921074
10931075public:
10941076 NullablePtr<ASTScopeImpl> insertionPointForDeferredExpansion () override ;
@@ -1123,10 +1105,6 @@ class DefaultArgumentInitializerScope final : public ASTScopeImpl {
11231105 virtual NullablePtr<DeclContext> getDeclContext () const override ;
11241106 virtual NullablePtr<Decl> getDeclIfAny () const override { return decl; }
11251107 Decl *getDecl () const { return decl; }
1126-
1127- protected:
1128- Optional<bool >
1129- resolveIsCascadingUseForThisScope (Optional<bool >) const override ;
11301108};
11311109
11321110// / Consider:
@@ -1274,9 +1252,6 @@ class PatternEntryInitializerScope final : public AbstractPatternEntryScope {
12741252protected:
12751253 bool lookupLocalsOrMembers (ArrayRef<const ASTScopeImpl *>,
12761254 DeclConsumer) const override ;
1277-
1278- Optional<bool >
1279- resolveIsCascadingUseForThisScope (Optional<bool >) const override ;
12801255};
12811256
12821257// / The scope introduced by a conditional clause in an if/guard/while
@@ -1392,6 +1367,42 @@ class ClosureParametersScope final : public ASTScopeImpl {
13921367 NullablePtr<Expr> getExprIfAny () const override { return closureExpr; }
13931368 Expr *getExpr () const { return closureExpr; }
13941369 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 () {}
13951406
13961407protected:
13971408 ASTScopeImpl *expandSpecifically (ScopeCreator &scopeCreator) override ;
@@ -1402,8 +1413,10 @@ class ClosureParametersScope final : public ASTScopeImpl {
14021413protected:
14031414 bool lookupLocalsOrMembers (ArrayRef<const ASTScopeImpl *>,
14041415 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 ;
14071420};
14081421
14091422class TopLevelCodeScope final : public ASTScopeImpl {
0 commit comments