@@ -1612,12 +1612,13 @@ class SequenceExpr : public Expr {
16121612};
16131613
16141614// / \brief A base class for closure expressions.
1615- class AbstractClosureExpr : public Expr {
1615+ class AbstractClosureExpr : public Expr , public DeclContext {
16161616 CaptureInfo Captures;
16171617
16181618public:
1619- AbstractClosureExpr (ExprKind Kind, Type FnType)
1620- : Expr(Kind, FnType)
1619+ AbstractClosureExpr (ExprKind Kind, Type FnType, DeclContext *Parent)
1620+ : Expr(Kind, FnType),
1621+ DeclContext (DeclContextKind::AbstractClosureExpr, Parent)
16211622 {}
16221623
16231624 CaptureInfo &getCaptureInfo () { return Captures; }
@@ -1627,12 +1628,18 @@ class AbstractClosureExpr : public Expr {
16271628 return E->getKind () >= ExprKind::First_AbstractClosureExpr &&
16281629 E->getKind () <= ExprKind::Last_AbstractClosureExpr;
16291630 }
1631+
1632+ static bool classof (const DeclContext *DC) {
1633+ return DC->getContextKind () == DeclContextKind::AbstractClosureExpr;
1634+ }
1635+
1636+ using DeclContext::operator new ;
16301637};
16311638
16321639// / An explicit unnamed func definition, which can optionally
16331640// / have named arguments.
16341641// / e.g. func(a : int) -> int { return a+1 }
1635- class PipeClosureExpr : public AbstractClosureExpr , public DeclContext {
1642+ class PipeClosureExpr : public AbstractClosureExpr {
16361643 // / \brief The set of parameters, along with a bit indicating when these
16371644 // / parameters were synthesized from anonymous closure variables.
16381645 llvm::PointerIntPair<Pattern *, 1 , bool > params;
@@ -1650,9 +1657,8 @@ class PipeClosureExpr : public AbstractClosureExpr, public DeclContext {
16501657
16511658public:
16521659 PipeClosureExpr (Pattern *params, SourceLoc arrowLoc,
1653- TypeLoc explicitResultType, DeclContext *parent)
1654- : AbstractClosureExpr(ExprKind::PipeClosure, Type()),
1655- DeclContext (DeclContextKind::PipeClosureExpr, parent),
1660+ TypeLoc explicitResultType, DeclContext *Parent)
1661+ : AbstractClosureExpr(ExprKind::PipeClosure, Type(), Parent),
16561662 params (params, false ), arrowLoc(arrowLoc),
16571663 explicitResultType(explicitResultType), body(nullptr ) { }
16581664
@@ -1738,14 +1744,6 @@ class PipeClosureExpr : public AbstractClosureExpr, public DeclContext {
17381744 static bool classof (const Expr *E) {
17391745 return E->getKind () == ExprKind::PipeClosure;
17401746 }
1741- static bool classof (const AbstractClosureExpr *E) {
1742- return classof (cast<Expr>(E));
1743- }
1744- static bool classof (const DeclContext *DC) {
1745- return DC->getContextKind () == DeclContextKind::PipeClosureExpr;
1746- }
1747-
1748- using DeclContext::operator new ;
17491747};
17501748
17511749// / \brief This is a closure of the contained subexpression that is formed
@@ -1754,14 +1752,13 @@ class PipeClosureExpr : public AbstractClosureExpr, public DeclContext {
17541752// / \code
17551753// / var x : [auto_closure] () -> int = 4
17561754// / \endcode
1757- class ImplicitClosureExpr : public AbstractClosureExpr , public DeclContext {
1755+ class ImplicitClosureExpr : public AbstractClosureExpr {
17581756 BraceStmt *Body;
17591757 Pattern *ParamPattern;
17601758
17611759public:
1762- ImplicitClosureExpr (Expr *Body, DeclContext *Parent, Type ResultTy)
1763- : AbstractClosureExpr(ExprKind::ImplicitClosure, ResultTy),
1764- DeclContext (DeclContextKind::ClosureExpr, Parent),
1760+ ImplicitClosureExpr (Expr *Body, Type ResultTy, DeclContext *Parent)
1761+ : AbstractClosureExpr(ExprKind::ImplicitClosure, ResultTy, Parent),
17651762 ParamPattern (nullptr ) {
17661763 setBody (Body);
17671764 }
@@ -1788,11 +1785,6 @@ class ImplicitClosureExpr : public AbstractClosureExpr, public DeclContext {
17881785 static bool classof (const Expr *E) {
17891786 return E->getKind () == ExprKind::ImplicitClosure;
17901787 }
1791- static bool classof (const DeclContext *DC) {
1792- return DC->getContextKind () == DeclContextKind::ClosureExpr;
1793- }
1794-
1795- using DeclContext::operator new ;
17961788};
17971789
17981790// / NewArrayExpr - The allocation of an array. Allocates and constructs
0 commit comments