@@ -183,10 +183,8 @@ enum class FixKind : uint8_t {
183
183
// / function to `Void` to conform to expected result type.
184
184
RemoveReturn,
185
185
186
- // / Generic parameters could not be inferred and have to be explicitly
187
- // / specified in the source. This fix groups all of the missing arguments
188
- // / associated with single declaration.
189
- ExplicitlySpecifyGenericArguments,
186
+ // / Default ambiguous generic arguments to \c Any
187
+ DefaultGenericArgument,
190
188
191
189
// / Skip any unhandled constructs that occur within a closure argument that
192
190
// / matches up with a
@@ -254,14 +252,18 @@ class ConstraintFix {
254
252
255
253
virtual std::string getName () const = 0;
256
254
257
- // / Diagnose a failure associated with this fix given
258
- // / root expression and information from constraint system.
259
- virtual bool diagnose (bool asNote = false ) const = 0;
260
-
261
- virtual ConstraintFix *coalescedWith (ArrayRef<ConstraintFix *> fixes) {
262
- return this ;
255
+ // / Coalesce this fix with the given secondary fixes and diagnose the failure.
256
+ // /
257
+ // / The default implementation ignores \c secondaryFixes and calls
258
+ // / \c diagnose.
259
+ virtual bool coalesceAndDiagnose (ArrayRef<ConstraintFix *> secondaryFixes,
260
+ bool asNote = false ) const {
261
+ return diagnose (asNote);
263
262
}
264
263
264
+ // / Diagnose a failure associated with this fix.
265
+ virtual bool diagnose (bool asNote = false ) const = 0;
266
+
265
267
void print (llvm::raw_ostream &Out) const ;
266
268
267
269
SWIFT_DEBUG_DUMP;
@@ -1251,49 +1253,32 @@ class CollectionElementContextualMismatch final : public ContextualMismatch {
1251
1253
ConstraintLocator *locator);
1252
1254
};
1253
1255
1254
- class ExplicitlySpecifyGenericArguments final
1255
- : public ConstraintFix,
1256
- private llvm::TrailingObjects<ExplicitlySpecifyGenericArguments,
1257
- GenericTypeParamType *> {
1258
- friend TrailingObjects;
1256
+ class DefaultGenericArgument final : public ConstraintFix {
1257
+ GenericTypeParamType *Param;
1259
1258
1260
- unsigned NumMissingParams;
1261
-
1262
- ExplicitlySpecifyGenericArguments (ConstraintSystem &cs,
1263
- ArrayRef<GenericTypeParamType *> params,
1264
- ConstraintLocator *locator)
1265
- : ConstraintFix(cs, FixKind::ExplicitlySpecifyGenericArguments, locator),
1266
- NumMissingParams (params.size()) {
1267
- assert (!params.empty ());
1268
- std::uninitialized_copy (params.begin (), params.end (),
1269
- getParametersBuf ().begin ());
1270
- }
1259
+ DefaultGenericArgument (ConstraintSystem &cs, GenericTypeParamType *param,
1260
+ ConstraintLocator *locator)
1261
+ : ConstraintFix(cs, FixKind::DefaultGenericArgument, locator),
1262
+ Param (param) {}
1271
1263
1272
1264
public:
1273
1265
static bool classof (const ConstraintFix *fix) {
1274
- return fix->getKind () == FixKind::ExplicitlySpecifyGenericArguments ;
1266
+ return fix->getKind () == FixKind::DefaultGenericArgument ;
1275
1267
}
1276
1268
1277
1269
std::string getName () const override {
1278
- return " default missing generic arguments to `Any`" ;
1270
+ auto paramName = Param->getString ();
1271
+ return " default generic argument '" + paramName + " ' to 'Any'" ;
1279
1272
}
1280
1273
1281
- ArrayRef<GenericTypeParamType *> getParameters () const {
1282
- return {getTrailingObjects<GenericTypeParamType *>(), NumMissingParams};
1283
- }
1274
+ bool coalesceAndDiagnose (ArrayRef<ConstraintFix *> secondaryFixes,
1275
+ bool asNote = false ) const override ;
1284
1276
1285
1277
bool diagnose (bool asNote = false ) const override ;
1286
1278
1287
- ConstraintFix *coalescedWith (ArrayRef<ConstraintFix *> fixes) override ;
1288
-
1289
- static ExplicitlySpecifyGenericArguments *
1290
- create (ConstraintSystem &cs, ArrayRef<GenericTypeParamType *> params,
1291
- ConstraintLocator *locator);
1292
-
1293
- private:
1294
- MutableArrayRef<GenericTypeParamType *> getParametersBuf () {
1295
- return {getTrailingObjects<GenericTypeParamType *>(), NumMissingParams};
1296
- }
1279
+ static DefaultGenericArgument *create (ConstraintSystem &cs,
1280
+ GenericTypeParamType *param,
1281
+ ConstraintLocator *locator);
1297
1282
};
1298
1283
1299
1284
class SkipUnhandledConstructInFunctionBuilder final : public ConstraintFix {
0 commit comments