@@ -278,28 +278,6 @@ class ConstraintFix {
278
278
ConstraintSystem &getConstraintSystem () const { return CS; }
279
279
};
280
280
281
- // / Introduce a '!' to force an optional unwrap.
282
- class ForceOptional final : public ConstraintFix {
283
- Type BaseType;
284
- Type UnwrappedType;
285
-
286
- ForceOptional (ConstraintSystem &cs, Type baseType, Type unwrappedType,
287
- ConstraintLocator *locator)
288
- : ConstraintFix(cs, FixKind::ForceOptional, locator), BaseType(baseType),
289
- UnwrappedType (unwrappedType) {
290
- assert (baseType && " Base type must not be null" );
291
- assert (unwrappedType && " Unwrapped type must not be null" );
292
- }
293
-
294
- public:
295
- std::string getName () const override { return " force optional" ; }
296
-
297
- bool diagnose (bool asNote = false ) const override ;
298
-
299
- static ForceOptional *create (ConstraintSystem &cs, Type baseType,
300
- Type unwrappedType, ConstraintLocator *locator);
301
- };
302
-
303
281
// / Unwrap an optional base when we have a member access.
304
282
class UnwrapOptionalBase final : public ConstraintFix {
305
283
DeclName MemberName;
@@ -514,6 +492,26 @@ class ContextualMismatch : public ConstraintFix {
514
492
ConstraintLocator *locator);
515
493
};
516
494
495
+ // / Introduce a '!' to force an optional unwrap.
496
+ class ForceOptional final : public ContextualMismatch {
497
+ ForceOptional (ConstraintSystem &cs, Type fromType, Type toType,
498
+ ConstraintLocator *locator)
499
+ : ContextualMismatch(cs, FixKind::ForceOptional, fromType, toType,
500
+ locator) {
501
+ assert (fromType && " Base type must not be null" );
502
+ assert (fromType->getOptionalObjectType () &&
503
+ " Unwrapped type must not be null" );
504
+ }
505
+
506
+ public:
507
+ std::string getName () const override { return " force optional" ; }
508
+
509
+ bool diagnose (bool asNote = false ) const override ;
510
+
511
+ static ForceOptional *create (ConstraintSystem &cs, Type fromType, Type toType,
512
+ ConstraintLocator *locator);
513
+ };
514
+
517
515
// / This is a contextual mismatch between throwing and non-throwing
518
516
// / function types, repair it by dropping `throws` attribute.
519
517
class DropThrowsAttribute final : public ContextualMismatch {
0 commit comments