Skip to content

Commit f3b3c39

Browse files
authored
[CS] Tweak addExplicitConversionConstraint slightly (#30687)
[CS] Tweak `addExplicitConversionConstraint` slightly
2 parents e5110d7 + 31e46b3 commit f3b3c39

File tree

3 files changed

+15
-12
lines changed

3 files changed

+15
-12
lines changed

lib/Sema/CSGen.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2978,8 +2978,8 @@ namespace {
29782978

29792979
// Add a conversion constraint for the direct conversion between
29802980
// types.
2981-
CS.addExplicitConversionConstraint(fromType, toType,
2982-
/*allowFixes=*/true, locator);
2981+
CS.addExplicitConversionConstraint(fromType, toType, RememberChoice,
2982+
locator);
29832983

29842984
// If the result type was declared IUO, add a disjunction for
29852985
// bindings for the result of the coercion.

lib/Sema/CSSimplify.cpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7291,13 +7291,13 @@ ConstraintSystem::simplifyBridgingConstraint(Type type1,
72917291
if (auto fromKeyValue = isDictionaryType(unwrappedFromType)) {
72927292
if (auto toKeyValue = isDictionaryType(unwrappedToType)) {
72937293
addExplicitConversionConstraint(fromKeyValue->first, toKeyValue->first,
7294-
/*allowFixes=*/false,
7294+
ForgetChoice,
72957295
locator.withPathElement(
72967296
LocatorPathElt::GenericArgument(0)));
72977297
addExplicitConversionConstraint(fromKeyValue->second, toKeyValue->second,
7298-
/*allowFixes=*/false,
7298+
ForgetChoice,
72997299
locator.withPathElement(
7300-
LocatorPathElt::GenericArgument(0)));
7300+
LocatorPathElt::GenericArgument(1)));
73017301
countOptionalInjections();
73027302
return SolutionKind::Solved;
73037303
}
@@ -9701,9 +9701,8 @@ void ConstraintSystem::addFixConstraint(ConstraintFix *fix, ConstraintKind kind,
97019701
}
97029702

97039703
void ConstraintSystem::addExplicitConversionConstraint(
9704-
Type fromType, Type toType,
9705-
bool allowFixes,
9706-
ConstraintLocatorBuilder locator) {
9704+
Type fromType, Type toType, RememberChoice_t rememberChoice,
9705+
ConstraintLocatorBuilder locator) {
97079706
SmallVector<Constraint *, 3> constraints;
97089707

97099708
auto locatorPtr = getConstraintLocator(locator);
@@ -9721,9 +9720,7 @@ void ConstraintSystem::addExplicitConversionConstraint(
97219720
fromType, toType, locatorPtr);
97229721
constraints.push_back(bridgingConstraint);
97239722

9724-
addDisjunctionConstraint(constraints, locator,
9725-
allowFixes ? RememberChoice
9726-
: ForgetChoice);
9723+
addDisjunctionConstraint(constraints, locator, rememberChoice);
97279724
}
97289725

97299726
ConstraintSystem::SolutionKind

lib/Sema/ConstraintSystem.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2855,8 +2855,14 @@ class ConstraintSystem {
28552855
}
28562856

28572857
/// Add an explicit conversion constraint (e.g., \c 'x as T').
2858+
///
2859+
/// \param fromType The type of the expression being converted.
2860+
/// \param toType The type to convert to.
2861+
/// \param rememberChoice Whether the conversion disjunction should record its
2862+
/// choice.
2863+
/// \param locator The locator.
28582864
void addExplicitConversionConstraint(Type fromType, Type toType,
2859-
bool allowFixes,
2865+
RememberChoice_t rememberChoice,
28602866
ConstraintLocatorBuilder locator);
28612867

28622868
/// Add a disjunction constraint.

0 commit comments

Comments
 (0)