@@ -728,20 +728,37 @@ class DefineMemberBasedOnUse final : public ConstraintFix {
728
728
ConstraintLocator *locator);
729
729
};
730
730
731
- class AllowMemberRefOnExistential final : public ConstraintFix {
731
+ class AllowInvalidMemberRef : public ConstraintFix {
732
732
Type BaseType;
733
+ ValueDecl *Member;
733
734
DeclName Name;
734
735
736
+ protected:
737
+ AllowInvalidMemberRef (ConstraintSystem &cs, FixKind kind, Type baseType,
738
+ ValueDecl *member, DeclName name,
739
+ ConstraintLocator *locator)
740
+ : ConstraintFix(cs, kind, locator), BaseType(baseType), Member(member),
741
+ Name (name) {}
742
+
743
+ public:
744
+ Type getBaseType () const { return BaseType; }
745
+
746
+ ValueDecl *getMember () const { return Member; }
747
+
748
+ DeclName getMemberName () const { return Name; }
749
+ };
750
+
751
+ class AllowMemberRefOnExistential final : public AllowInvalidMemberRef {
735
752
AllowMemberRefOnExistential (ConstraintSystem &cs, Type baseType,
736
753
DeclName memberName, ValueDecl *member,
737
754
ConstraintLocator *locator)
738
- : ConstraintFix (cs, FixKind::AllowMemberRefOnExistential, locator) ,
739
- BaseType ( baseType), Name( memberName) {}
755
+ : AllowInvalidMemberRef (cs, FixKind::AllowMemberRefOnExistential,
756
+ baseType, member, memberName, locator ) {}
740
757
741
758
public:
742
759
std::string getName () const override {
743
760
llvm::SmallVector<char , 16 > scratch;
744
- auto memberName = Name .getString (scratch);
761
+ auto memberName = getMemberName () .getString (scratch);
745
762
return " allow access to invalid member '" + memberName.str () +
746
763
" ' on value of protocol type" ;
747
764
}
@@ -754,20 +771,16 @@ class AllowMemberRefOnExistential final : public ConstraintFix {
754
771
ConstraintLocator *locator);
755
772
};
756
773
757
- class AllowTypeOrInstanceMember final : public ConstraintFix {
758
- Type BaseType;
759
- ValueDecl *Member;
760
- DeclName UsedName;
761
-
762
- public:
774
+ class AllowTypeOrInstanceMember final : public AllowInvalidMemberRef {
763
775
AllowTypeOrInstanceMember (ConstraintSystem &cs, Type baseType,
764
776
ValueDecl *member, DeclName name,
765
777
ConstraintLocator *locator)
766
- : ConstraintFix (cs, FixKind::AllowTypeOrInstanceMember, locator) ,
767
- BaseType (baseType), Member( member), UsedName( name) {
778
+ : AllowInvalidMemberRef (cs, FixKind::AllowTypeOrInstanceMember, baseType ,
779
+ member, name, locator ) {
768
780
assert (member);
769
781
}
770
782
783
+ public:
771
784
std::string getName () const override {
772
785
return " allow access to instance member on type or a type member on instance" ;
773
786
}
@@ -934,13 +947,12 @@ class MoveOutOfOrderArgument final : public ConstraintFix {
934
947
ConstraintLocator *locator);
935
948
};
936
949
937
- class AllowInaccessibleMember final : public ConstraintFix {
938
- ValueDecl *Member;
939
-
940
- AllowInaccessibleMember (ConstraintSystem &cs, ValueDecl *member,
950
+ class AllowInaccessibleMember final : public AllowInvalidMemberRef {
951
+ AllowInaccessibleMember (ConstraintSystem &cs, Type baseType,
952
+ ValueDecl *member, DeclName name,
941
953
ConstraintLocator *locator)
942
- : ConstraintFix (cs, FixKind::AllowInaccessibleMember, locator) ,
943
- Member ( member) {}
954
+ : AllowInvalidMemberRef (cs, FixKind::AllowInaccessibleMember, baseType ,
955
+ member, name, locator ) {}
944
956
945
957
public:
946
958
std::string getName () const override {
@@ -949,8 +961,8 @@ class AllowInaccessibleMember final : public ConstraintFix {
949
961
950
962
bool diagnose (Expr *root, bool asNote = false ) const override ;
951
963
952
- static AllowInaccessibleMember *create (ConstraintSystem &cs,
953
- ValueDecl *member,
964
+ static AllowInaccessibleMember *create (ConstraintSystem &cs, Type baseType,
965
+ ValueDecl *member, DeclName name,
954
966
ConstraintLocator *locator);
955
967
};
956
968
0 commit comments