Skip to content

Commit 8845fcb

Browse files
Suyash SrijanSuyash Srijan
authored andcommitted
[cs] use anchor from locator when creating a ForceOptional fix
1 parent 6a0a1de commit 8845fcb

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2394,7 +2394,7 @@ ConstraintSystem::matchTypes(Type type1, Type type2, ConstraintKind kind,
23942394
if (forceUnwrapPossible) {
23952395
conversionsOrFixes.push_back(ForceOptional::create(
23962396
*this, objectType1, objectType1->getOptionalObjectType(),
2397-
getConstraintLocator(locator)));
2397+
getConstraintLocator(locator.getAnchor())));
23982398
}
23992399
}
24002400

@@ -2744,7 +2744,7 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyConformsToConstraint(
27442744
subflags);
27452745
if (result == SolutionKind::Solved) {
27462746
auto *fix = ForceOptional::create(*this, type, optionalObjectType,
2747-
getConstraintLocator(locator));
2747+
getConstraintLocator(locator.getAnchor()));
27482748
if (recordFix(fix)) {
27492749
return SolutionKind::Error;
27502750
}
@@ -3042,7 +3042,7 @@ ConstraintSystem::simplifyFunctionComponentConstraint(
30423042
if (unwrapCount > 0) {
30433043
auto *fix = ForceOptional::create(*this, simplifiedCopy,
30443044
simplifiedCopy->getOptionalObjectType(),
3045-
getConstraintLocator(locator));
3045+
getConstraintLocator(locator.getAnchor()));
30463046
while (unwrapCount-- > 0) {
30473047
if (recordFix(fix))
30483048
return SolutionKind::Error;
@@ -4668,7 +4668,7 @@ ConstraintSystem::simplifyApplicableFnConstraint(
46684668
// Record any fixes we attempted to get to the correct solution.
46694669
auto *fix = ForceOptional::create(*this, origType2,
46704670
origType2->getOptionalObjectType(),
4671-
getConstraintLocator(locator));
4671+
getConstraintLocator(locator.getAnchor()));
46724672
while (unwrapCount-- > 0) {
46734673
if (recordFix(fix))
46744674
return SolutionKind::Error;
@@ -4693,7 +4693,7 @@ ConstraintSystem::simplifyApplicableFnConstraint(
46934693
if (simplified == SolutionKind::Solved) {
46944694
auto *fix = ForceOptional::create(*this, origType2,
46954695
origType2->getOptionalObjectType(),
4696-
getConstraintLocator(locator));
4696+
getConstraintLocator(locator.getAnchor()));
46974697
while (unwrapCount-- > 0) {
46984698
if (recordFix(fix))
46994699
return SolutionKind::Error;
@@ -5409,12 +5409,7 @@ bool ConstraintSystem::recordFix(ConstraintFix *fix) {
54095409
// This situation might happen when the same fix kind is applicable to
54105410
// different overload choices.
54115411
auto *loc = fix->getLocator();
5412-
auto *anchor = loc->getAnchor();
54135412
auto existingFix = llvm::find_if(Fixes, [&](const ConstraintFix *e) {
5414-
if (e->getKind() == FixKind::ForceOptional &&
5415-
e->getLocator()->getAnchor() == anchor) {
5416-
return true;
5417-
}
54185413
// If we already have a fix like this recorded, let's not do it again,
54195414
return e->getKind() == fix->getKind() && e->getLocator() == loc;
54205415
});

0 commit comments

Comments
 (0)