Skip to content

Commit 9b688e9

Browse files
committed
[CSFix] Move diagnoseForAmbiguity to RequirementFix
The logic is common for all types of fixes that represent a requirement failure.
1 parent edb6ef0 commit 9b688e9

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

include/swift/Sema/CSFix.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,8 @@ class RequirementFix : public ConstraintFix {
612612
Type lhsType() const { return LHS; }
613613
Type rhsType() const { return RHS; }
614614

615+
bool diagnoseForAmbiguity(CommonFixesArray commonFixes) const override;
616+
615617
bool diagnose(const Solution &solution,
616618
bool asNote = false) const override = 0;
617619
};
@@ -635,8 +637,6 @@ class MissingConformance final : public RequirementFix {
635637

636638
bool diagnose(const Solution &solution, bool asNote = false) const override;
637639

638-
bool diagnoseForAmbiguity(CommonFixesArray commonFixes) const override;
639-
640640
static MissingConformance *forRequirement(ConstraintSystem &cs, Type type,
641641
Type protocolType,
642642
ConstraintLocator *locator);

lib/Sema/CSFix.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -410,16 +410,16 @@ bool MissingConformance::diagnose(const Solution &solution, bool asNote) const {
410410
return failure.diagnose(asNote);
411411
}
412412

413-
bool MissingConformance::diagnoseForAmbiguity(
413+
bool RequirementFix::diagnoseForAmbiguity(
414414
CommonFixesArray commonFixes) const {
415-
auto *primaryFix = commonFixes.front().second->getAs<MissingConformance>();
415+
auto *primaryFix = commonFixes.front().second;
416416
assert(primaryFix);
417417

418418
if (llvm::all_of(
419419
commonFixes,
420420
[&primaryFix](
421421
const std::pair<const Solution *, const ConstraintFix *> &entry) {
422-
return primaryFix->isEqual(entry.second);
422+
return primaryFix->getLocator() == entry.second->getLocator();
423423
}))
424424
return diagnose(*commonFixes.front().first);
425425

0 commit comments

Comments
 (0)