2929#include " swift/AST/FunctionRefInfo.h"
3030#include " swift/AST/ProtocolConformanceRef.h"
3131#include " swift/AST/ThrownErrorDestination.h"
32+ #include " swift/AST/Type.h"
3233#include " swift/AST/TypeAlignments.h"
3334#include " swift/Basic/Debug.h"
3435#include " swift/Basic/InlineBitfield.h"
@@ -3367,9 +3368,8 @@ class UnresolvedTypeConversionExpr : public ImplicitConversionExpr {
33673368// / FIXME: This should be a CapturingExpr.
33683369class FunctionConversionExpr : public ImplicitConversionExpr {
33693370public:
3370- FunctionConversionExpr (Expr *subExpr, Type type)
3371- : ImplicitConversionExpr(ExprKind::FunctionConversion, subExpr, type) {}
3372-
3371+ FunctionConversionExpr (Expr *subExpr, Type type);
3372+
33733373 static bool classof (const Expr *E) {
33743374 return E->getKind () == ExprKind::FunctionConversion;
33753375 }
@@ -4290,6 +4290,12 @@ class ClosureExpr : public AbstractClosureExpr {
42904290 // / The body of the closure.
42914291 BraceStmt *Body;
42924292
4293+ // / Used when lowering ClosureExprs to C function pointers.
4294+ // / This is required to access the ClangType from SILDeclRef.
4295+ // / TODO: this will be redundant after we preserve ClangTypes
4296+ // / in the canonical types.
4297+ FunctionConversionExpr *ConvertedTo;
4298+
42934299 friend class GlobalActorAttributeRequest ;
42944300
42954301 bool hasNoGlobalActorAttribute () const {
@@ -4301,19 +4307,19 @@ class ClosureExpr : public AbstractClosureExpr {
43014307 }
43024308
43034309public:
4304- ClosureExpr (const DeclAttributes &attributes,
4305- SourceRange bracketRange, VarDecl *capturedSelfDecl ,
4306- ParameterList *params, SourceLoc asyncLoc, SourceLoc throwsLoc,
4307- TypeExpr *thrownType, SourceLoc arrowLoc, SourceLoc inLoc,
4308- TypeExpr *explicitResultType, DeclContext *parent)
4309- : AbstractClosureExpr(ExprKind::Closure, Type(), /* Implicit=*/ false ,
4310- parent),
4311- Attributes (attributes), BracketRange(bracketRange),
4312- CapturedSelfDecl(capturedSelfDecl),
4313- AsyncLoc(asyncLoc), ThrowsLoc(throwsLoc), ArrowLoc(arrowLoc),
4314- InLoc(inLoc), ThrownType(thrownType),
4315- ExplicitResultTypeAndBodyState(explicitResultType, BodyState::Parsed),
4316- Body(nullptr ) {
4310+ ClosureExpr (const DeclAttributes &attributes, SourceRange bracketRange,
4311+ VarDecl *capturedSelfDecl, ParameterList *params ,
4312+ SourceLoc asyncLoc, SourceLoc throwsLoc, TypeExpr *thrownType ,
4313+ SourceLoc arrowLoc, SourceLoc inLoc, TypeExpr *explicitResultType ,
4314+ DeclContext *parent)
4315+ : AbstractClosureExpr(ExprKind::Closure, Type(), /* Implicit=*/ false ,
4316+ parent),
4317+ Attributes (attributes), BracketRange(bracketRange),
4318+ CapturedSelfDecl(capturedSelfDecl), AsyncLoc(asyncLoc ),
4319+ ThrowsLoc(throwsLoc), ArrowLoc(arrowLoc), InLoc(inLoc ),
4320+ ThrownType(thrownType),
4321+ ExplicitResultTypeAndBodyState(explicitResultType, BodyState::Parsed),
4322+ Body( nullptr ), ConvertedTo (nullptr ) {
43174323 setParameterList (params);
43184324 Bits.ClosureExpr .HasAnonymousClosureVars = false ;
43194325 Bits.ClosureExpr .ImplicitSelfCapture = false ;
@@ -4506,6 +4512,9 @@ class ClosureExpr : public AbstractClosureExpr {
45064512 ExplicitResultTypeAndBodyState.setInt (v);
45074513 }
45084514
4515+ const FunctionConversionExpr *getConvertedTo () const { return ConvertedTo; }
4516+ void setConvertedTo (FunctionConversionExpr *e) { ConvertedTo = e; }
4517+
45094518 static bool classof (const Expr *E) {
45104519 return E->getKind () == ExprKind::Closure;
45114520 }
0 commit comments