File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -1520,10 +1520,18 @@ class AllowInvalidRefInKeyPath final : public ConstraintFix {
1520
1520
1521
1521
bool diagnose (const Solution &solution, bool asNote = false ) const override ;
1522
1522
1523
+ bool diagnoseForAmbiguity (CommonFixesArray commonFixes) const override ;
1524
+
1523
1525
// / Determine whether give reference requires a fix and produce one.
1524
1526
static AllowInvalidRefInKeyPath *
1525
1527
forRef (ConstraintSystem &cs, ValueDecl *member, ConstraintLocator *locator);
1526
1528
1529
+ bool isEqual (const ConstraintFix *other) const ;
1530
+
1531
+ static bool classof (const ConstraintFix *fix) {
1532
+ return fix->getKind () == FixKind::AllowInvalidRefInKeyPath;
1533
+ }
1534
+
1527
1535
private:
1528
1536
static AllowInvalidRefInKeyPath *create (ConstraintSystem &cs, RefKind kind,
1529
1537
ValueDecl *member,
Original file line number Diff line number Diff line change @@ -953,6 +953,29 @@ bool AllowInvalidRefInKeyPath::diagnose(const Solution &solution,
953
953
llvm_unreachable (" covered switch" );
954
954
}
955
955
956
+ bool AllowInvalidRefInKeyPath::diagnoseForAmbiguity (
957
+ CommonFixesArray commonFixes) const {
958
+ auto *primaryFix =
959
+ commonFixes.front ().second ->getAs <AllowInvalidRefInKeyPath>();
960
+ assert (primaryFix);
961
+
962
+ if (llvm::all_of (
963
+ commonFixes,
964
+ [&primaryFix](
965
+ const std::pair<const Solution *, const ConstraintFix *> &entry) {
966
+ return primaryFix->isEqual (entry.second );
967
+ })) {
968
+ return diagnose (*commonFixes.front ().first );
969
+ }
970
+
971
+ return false ;
972
+ }
973
+
974
+ bool AllowInvalidRefInKeyPath::isEqual (const ConstraintFix *other) const {
975
+ auto *refFix = other->getAs <AllowInvalidRefInKeyPath>();
976
+ return refFix ? Kind == refFix->Kind && Member == refFix->Member : false ;
977
+ }
978
+
956
979
AllowInvalidRefInKeyPath *
957
980
AllowInvalidRefInKeyPath::forRef (ConstraintSystem &cs, ValueDecl *member,
958
981
ConstraintLocator *locator) {
You can’t perform that action at this time.
0 commit comments