@@ -223,6 +223,10 @@ enum class FixKind : uint8_t {
223
223
// / Allow an ephemeral argument conversion for a parameter marked as being
224
224
// / non-ephemeral.
225
225
TreatEphemeralAsNonEphemeral,
226
+
227
+ // / Base type in reference to the contextual member e.g. `.foo` couldn't be
228
+ // / inferred and has to be specified explicitly.
229
+ SpecifyBaseTypeForContextualMember,
226
230
};
227
231
228
232
class ConstraintFix {
@@ -1535,6 +1539,27 @@ class TreatEphemeralAsNonEphemeral final : public AllowArgumentMismatch {
1535
1539
bool downgradeToWarning);
1536
1540
};
1537
1541
1542
+ class SpecifyBaseTypeForContextualMember final : public ConstraintFix {
1543
+ DeclName MemberName;
1544
+
1545
+ SpecifyBaseTypeForContextualMember (ConstraintSystem &cs, DeclName member,
1546
+ ConstraintLocator *locator)
1547
+ : ConstraintFix(cs, FixKind::SpecifyBaseTypeForContextualMember, locator),
1548
+ MemberName (member) {}
1549
+
1550
+ public:
1551
+ std::string getName () const {
1552
+ const auto baseName = MemberName.getBaseName ();
1553
+ return " specify base type in reference to member '" +
1554
+ baseName.userFacingName ().str () + " '" ;
1555
+ }
1556
+
1557
+ bool diagnose (bool asNote = false ) const ;
1558
+
1559
+ static SpecifyBaseTypeForContextualMember *
1560
+ create (ConstraintSystem &cs, DeclName member, ConstraintLocator *locator);
1561
+ };
1562
+
1538
1563
} // end namespace constraints
1539
1564
} // end namespace swift
1540
1565
0 commit comments