Skip to content

Commit 6cebc92

Browse files
committed
[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 4f7f5d7 commit 6cebc92

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
@@ -4753,28 +4753,40 @@ ConstraintSystem::simplifyFixConstraint(Fix fix, Type type1, Type type2,
47534753
ConstraintKind matchKind,
47544754
TypeMatchOptions flags,
47554755
ConstraintLocatorBuilder locator) {
4756-
if (recordFix(fix, locator))
4757-
return SolutionKind::Error;
4758-
47594756
// Try with the fix.
47604757
TypeMatchOptions subflags =
47614758
getDefaultDecompositionOptions(flags) | TMF_ApplyingFix;
47624759
switch (fix.getKind()) {
47634760
case FixKind::ForceOptional:
4764-
case FixKind::OptionalChaining:
4761+
case FixKind::OptionalChaining: {
47654762
// Assume that '!' was applied to the first type.
4766-
return matchTypes(type1->getRValueObjectType()->getOptionalObjectType(),
4767-
type2, matchKind, subflags, locator);
4763+
auto result =
4764+
matchTypes(type1->getRValueObjectType()->getOptionalObjectType(), type2,
4765+
matchKind, subflags, locator);
4766+
if (result == SolutionKind::Solved)
4767+
if (recordFix(fix, locator))
4768+
return SolutionKind::Error;
47684769

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

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

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

0 commit comments

Comments
 (0)