@@ -3774,7 +3774,7 @@ class ClosureExpr : public AbstractClosureExpr {
3774
3774
// / The bit indicates whether this closure has had a function builder
3775
3775
// / applied to it.
3776
3776
llvm::PointerIntPair<VarDecl *, 1 , bool > CapturedSelfDeclAndAppliedBuilder;
3777
-
3777
+
3778
3778
// / The location of the "throws", if present.
3779
3779
SourceLoc ThrowsLoc;
3780
3780
@@ -3786,7 +3786,8 @@ class ClosureExpr : public AbstractClosureExpr {
3786
3786
SourceLoc InLoc;
3787
3787
3788
3788
// / The explicitly-specified result type.
3789
- TypeExpr *ExplicitResultType;
3789
+ llvm::PointerIntPair<TypeExpr *, 1 , bool >
3790
+ ExplicitResultTypeAndEnclosingChecked;
3790
3791
3791
3792
// / The body of the closure, along with a bit indicating whether it
3792
3793
// / was originally just a single expression.
@@ -3801,7 +3802,8 @@ class ClosureExpr : public AbstractClosureExpr {
3801
3802
BracketRange (bracketRange),
3802
3803
CapturedSelfDeclAndAppliedBuilder(capturedSelfDecl, false ),
3803
3804
ThrowsLoc(throwsLoc), ArrowLoc(arrowLoc), InLoc(inLoc),
3804
- ExplicitResultType(explicitResultType), Body(nullptr ) {
3805
+ ExplicitResultTypeAndEnclosingChecked(explicitResultType, false ),
3806
+ Body(nullptr ) {
3805
3807
setParameterList (params);
3806
3808
Bits.ClosureExpr .HasAnonymousClosureVars = false ;
3807
3809
}
@@ -3855,13 +3857,15 @@ class ClosureExpr : public AbstractClosureExpr {
3855
3857
3856
3858
Type getExplicitResultType () const {
3857
3859
assert (hasExplicitResultType () && " No explicit result type" );
3858
- return ExplicitResultType->getInstanceType ();
3860
+ return ExplicitResultTypeAndEnclosingChecked.getPointer ()
3861
+ ->getInstanceType ();
3859
3862
}
3860
3863
void setExplicitResultType (Type ty);
3861
3864
3862
3865
TypeRepr *getExplicitResultTypeRepr () const {
3863
3866
assert (hasExplicitResultType () && " No explicit result type" );
3864
- return ExplicitResultType->getTypeRepr ();
3867
+ return ExplicitResultTypeAndEnclosingChecked.getPointer ()
3868
+ ->getTypeRepr ();
3865
3869
}
3866
3870
3867
3871
// / Determine whether the closure has a single expression for its
@@ -3918,6 +3922,16 @@ class ClosureExpr : public AbstractClosureExpr {
3918
3922
CapturedSelfDeclAndAppliedBuilder.setInt (flag);
3919
3923
}
3920
3924
3925
+ // / Whether this closure's body was type checked within the enclosing
3926
+ // / context.
3927
+ bool wasTypeCheckedInEnclosingContext () const {
3928
+ return ExplicitResultTypeAndEnclosingChecked.getInt ();
3929
+ }
3930
+
3931
+ void setTypeCheckedInEnclosingContext (bool flag = true ) {
3932
+ ExplicitResultTypeAndEnclosingChecked.setInt (flag);
3933
+ }
3934
+
3921
3935
static bool classof (const Expr *E) {
3922
3936
return E->getKind () == ExprKind::Closure;
3923
3937
}
0 commit comments