@@ -462,9 +462,12 @@ enum class FixKind : uint8_t {
462462 // / because its name doesn't appear in 'initializes' or 'accesses' attributes.
463463 AllowInvalidMemberReferenceInInitAccessor,
464464
465- // / Ignore an attempt to specialize non-generic type.
465+ // / Ignore an attempt to specialize a non-generic type.
466466 AllowConcreteTypeSpecialization,
467467
468+ // / Ignore an attempt to specialize a generic function.
469+ AllowGenericFunctionSpecialization,
470+
468471 // / Ignore an out-of-place \c then statement.
469472 IgnoreOutOfPlaceThenStmt,
470473
@@ -3718,11 +3721,14 @@ class AllowInvalidMemberReferenceInInitAccessor final : public ConstraintFix {
37183721
37193722class AllowConcreteTypeSpecialization final : public ConstraintFix {
37203723 Type ConcreteType;
3724+ ValueDecl *Decl;
37213725
37223726 AllowConcreteTypeSpecialization (ConstraintSystem &cs, Type concreteTy,
3723- ConstraintLocator *locator)
3724- : ConstraintFix(cs, FixKind::AllowConcreteTypeSpecialization, locator),
3725- ConcreteType (concreteTy) {}
3727+ ValueDecl *decl, ConstraintLocator *locator,
3728+ FixBehavior fixBehavior)
3729+ : ConstraintFix(cs, FixKind::AllowConcreteTypeSpecialization, locator,
3730+ fixBehavior),
3731+ ConcreteType (concreteTy), Decl(decl) {}
37263732
37273733public:
37283734 std::string getName () const override {
@@ -3736,13 +3742,41 @@ class AllowConcreteTypeSpecialization final : public ConstraintFix {
37363742 }
37373743
37383744 static AllowConcreteTypeSpecialization *
3739- create (ConstraintSystem &cs, Type concreteTy, ConstraintLocator *locator);
3745+ create (ConstraintSystem &cs, Type concreteTy, ValueDecl *decl,
3746+ ConstraintLocator *locator, FixBehavior fixBehavior);
37403747
37413748 static bool classof (const ConstraintFix *fix) {
37423749 return fix->getKind () == FixKind::AllowConcreteTypeSpecialization;
37433750 }
37443751};
37453752
3753+ class AllowGenericFunctionSpecialization final : public ConstraintFix {
3754+ ValueDecl *Decl;
3755+
3756+ AllowGenericFunctionSpecialization (ConstraintSystem &cs, ValueDecl *decl,
3757+ ConstraintLocator *locator)
3758+ : ConstraintFix(cs, FixKind::AllowGenericFunctionSpecialization, locator),
3759+ Decl (decl) {}
3760+
3761+ public:
3762+ std::string getName () const override {
3763+ return " allow generic function specialization" ;
3764+ }
3765+
3766+ bool diagnose (const Solution &solution, bool asNote = false ) const override ;
3767+
3768+ bool diagnoseForAmbiguity (CommonFixesArray commonFixes) const override {
3769+ return diagnose (*commonFixes.front ().first );
3770+ }
3771+
3772+ static AllowGenericFunctionSpecialization *
3773+ create (ConstraintSystem &cs, ValueDecl *decl, ConstraintLocator *locator);
3774+
3775+ static bool classof (const ConstraintFix *fix) {
3776+ return fix->getKind () == FixKind::AllowGenericFunctionSpecialization;
3777+ }
3778+ };
3779+
37463780class IgnoreOutOfPlaceThenStmt final : public ConstraintFix {
37473781 IgnoreOutOfPlaceThenStmt (ConstraintSystem &cs, ConstraintLocator *locator)
37483782 : ConstraintFix(cs, FixKind::IgnoreOutOfPlaceThenStmt, locator) {}
0 commit comments