@@ -105,6 +105,50 @@ enum class FreeTypeVariableBinding {
105
105
106
106
namespace constraints {
107
107
108
+ struct ResultBuilder {
109
+ private:
110
+ DeclContext *DC;
111
+ // / An implicit variable that represents `Self` type of the result builder.
112
+ VarDecl *BuilderSelf;
113
+ Type BuilderType;
114
+ llvm::SmallDenseMap<DeclName, bool > SupportedOps;
115
+
116
+ Identifier BuildOptionalId;
117
+
118
+ // / Counter used to give unique names to the variables that are
119
+ // / created implicitly.
120
+ unsigned VarCounter = 0 ;
121
+
122
+ public:
123
+ ResultBuilder (ConstraintSystem *CS, DeclContext *DC, Type builderType);
124
+
125
+ DeclContext *getDeclContext () const { return DC; }
126
+
127
+ Type getType () const { return BuilderType; }
128
+
129
+ NominalTypeDecl *getBuilderDecl () const {
130
+ return BuilderType->getAnyNominal ();
131
+ }
132
+
133
+ Identifier getBuildOptionalId () const { return BuildOptionalId; }
134
+
135
+ bool supports (Identifier fnBaseName, ArrayRef<Identifier> argLabels = {},
136
+ bool checkAvailability = false );
137
+
138
+ bool supportsOptional () { return supports (getBuildOptionalId ()); }
139
+
140
+ Expr *buildCall (SourceLoc loc, Identifier fnName,
141
+ ArrayRef<Expr *> argExprs,
142
+ ArrayRef<Identifier> argLabels) const ;
143
+
144
+ // / Build an implicit variable in this context.
145
+ VarDecl *buildVar (SourceLoc loc);
146
+
147
+ // / Build a reference to a given variable and mark it
148
+ // / as located at a given source location.
149
+ DeclRefExpr *buildVarRef (VarDecl *var, SourceLoc loc);
150
+ };
151
+
108
152
// / Describes the algorithm to use for trailing closure matching.
109
153
enum class TrailingClosureMatching {
110
154
// / Match a trailing closure to the first parameter that appears to work.
0 commit comments