@@ -1031,6 +1031,26 @@ class KeyPathSubscriptIndexHashableFailure final : public FailureDiagnostic {
1031
1031
bool diagnoseAsError () override ;
1032
1032
};
1033
1033
1034
+ class InvalidMemberRefInKeyPath : public FailureDiagnostic {
1035
+ ValueDecl *Member;
1036
+
1037
+ public:
1038
+ InvalidMemberRefInKeyPath (Expr *root, ConstraintSystem &cs, ValueDecl *member,
1039
+ ConstraintLocator *locator)
1040
+ : FailureDiagnostic(root, cs, locator), Member(member) {
1041
+ assert (member->hasName ());
1042
+ assert (locator->isForKeyPathComponent ());
1043
+ }
1044
+
1045
+ DeclName getName () const { return Member->getFullName (); }
1046
+
1047
+ bool diagnoseAsError () override = 0;
1048
+
1049
+ protected:
1050
+ // / Compute location of the failure for diagnostic.
1051
+ SourceLoc getLoc () const ;
1052
+ };
1053
+
1034
1054
// / Diagnose an attempt to reference a static member as a key path component
1035
1055
// / e.g.
1036
1056
// /
@@ -1041,16 +1061,11 @@ class KeyPathSubscriptIndexHashableFailure final : public FailureDiagnostic {
1041
1061
// /
1042
1062
// / _ = \S.Type.foo
1043
1063
// / ```
1044
- class InvalidStaticMemberRefInKeyPath final : public FailureDiagnostic {
1045
- ValueDecl *Member;
1046
-
1064
+ class InvalidStaticMemberRefInKeyPath final : public InvalidMemberRefInKeyPath {
1047
1065
public:
1048
1066
InvalidStaticMemberRefInKeyPath (Expr *root, ConstraintSystem &cs,
1049
1067
ValueDecl *member, ConstraintLocator *locator)
1050
- : FailureDiagnostic(root, cs, locator), Member(member) {
1051
- assert (member->hasName ());
1052
- assert (locator->isForKeyPathComponent ());
1053
- }
1068
+ : InvalidMemberRefInKeyPath(root, cs, member, locator) {}
1054
1069
1055
1070
bool diagnoseAsError () override ;
1056
1071
};
0 commit comments