Skip to content

Commit 6d0acd2

Browse files
rudkxDavid Ungar
authored andcommitted
[ConstraintSystem] Only record fixes that result in a correct solution.
It's probably harmless to record the ones for failures which later cause us to back out in the solver, but it means we cannot easily set breakpoints in places like recordFix and stop only in the places where the fixes actually cause the solution to make progress.
1 parent efc2b64 commit 6d0acd2

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4752,28 +4752,40 @@ ConstraintSystem::simplifyFixConstraint(Fix fix, Type type1, Type type2,
47524752
ConstraintKind matchKind,
47534753
TypeMatchOptions flags,
47544754
ConstraintLocatorBuilder locator) {
4755-
if (recordFix(fix, locator))
4756-
return SolutionKind::Error;
4757-
47584755
// Try with the fix.
47594756
TypeMatchOptions subflags =
47604757
getDefaultDecompositionOptions(flags) | TMF_ApplyingFix;
47614758
switch (fix.getKind()) {
47624759
case FixKind::ForceOptional:
4763-
case FixKind::OptionalChaining:
4760+
case FixKind::OptionalChaining: {
47644761
// Assume that '!' was applied to the first type.
4765-
return matchTypes(type1->getRValueObjectType()->getOptionalObjectType(),
4766-
type2, matchKind, subflags, locator);
4762+
auto result =
4763+
matchTypes(type1->getRValueObjectType()->getOptionalObjectType(), type2,
4764+
matchKind, subflags, locator);
4765+
if (result == SolutionKind::Solved)
4766+
if (recordFix(fix, locator))
4767+
return SolutionKind::Error;
47674768

4769+
return result;
4770+
}
47684771
case FixKind::ForceDowncast:
47694772
// These work whenever they are suggested.
4773+
if (recordFix(fix, locator))
4774+
return SolutionKind::Error;
4775+
47704776
return SolutionKind::Solved;
47714777

4772-
case FixKind::AddressOf:
4778+
case FixKind::AddressOf: {
47734779
// Assume that '&' was applied to the first type, turning an lvalue into
47744780
// an inout.
4775-
return matchTypes(InOutType::get(type1->getRValueType()), type2,
4776-
matchKind, subflags, locator);
4781+
auto result = matchTypes(InOutType::get(type1->getRValueType()), type2,
4782+
matchKind, subflags, locator);
4783+
if (result == SolutionKind::Solved)
4784+
if (recordFix(fix, locator))
4785+
return SolutionKind::Error;
4786+
4787+
return result;
4788+
}
47774789

47784790
case FixKind::CoerceToCheckedCast:
47794791
llvm_unreachable("handled elsewhere");

0 commit comments

Comments
 (0)