@@ -3902,9 +3902,8 @@ bool ConstraintSystem::repairFailures(
3902
3902
// If the result type of the coercion has an value to optional conversion
3903
3903
// we can instead suggest the conditional downcast as it is safer in
3904
3904
// situations like conditional binding.
3905
- auto useConditionalCast = llvm::any_of(
3906
- ConstraintRestrictions,
3907
- [&](std::tuple<Type, Type, ConversionRestrictionKind> restriction) {
3905
+ auto useConditionalCast =
3906
+ llvm::any_of(ConstraintRestrictions, [&](auto &restriction) {
3908
3907
ConversionRestrictionKind restrictionKind;
3909
3908
Type type1, type2;
3910
3909
std::tie(type1, type2, restrictionKind) = restriction;
@@ -6710,8 +6709,7 @@ static ConstraintFix *maybeWarnAboutExtraneousCast(
6710
6709
ConstraintSystem &cs, Type origFromType, Type origToType, Type fromType,
6711
6710
Type toType, SmallVector<Type, 4> fromOptionals,
6712
6711
SmallVector<Type, 4> toOptionals,
6713
- const std::vector<std::tuple<Type, Type, ConversionRestrictionKind>>
6714
- &constraintRestrictions,
6712
+ const std::vector<ConversionRestriction> &constraintRestrictions,
6715
6713
ConstraintSystem::TypeMatchOptions flags,
6716
6714
ConstraintLocatorBuilder locator) {
6717
6715
@@ -6738,14 +6736,10 @@ static ConstraintFix *maybeWarnAboutExtraneousCast(
6738
6736
// "from" expression could be a type variable with value-to-optional
6739
6737
// restrictions that we have to account for optionality mismatch.
6740
6738
const auto subExprType = cs.getType(castExpr->getSubExpr());
6741
- if (llvm::any_of(constraintRestrictions, [&](auto &entry) {
6742
- Type type1, type2;
6743
- ConversionRestrictionKind kind;
6744
- std::tie(type1, type2, kind) = entry;
6745
- if (kind != ConversionRestrictionKind::ValueToOptional)
6746
- return false;
6747
- return fromType->isEqual(type1) && subExprType->isEqual(type2);
6748
- })) {
6739
+ if (llvm::is_contained(
6740
+ constraintRestrictions,
6741
+ std::make_tuple(fromType.getPointer(), subExprType.getPointer(),
6742
+ ConversionRestrictionKind::ValueToOptional))) {
6749
6743
extraOptionals++;
6750
6744
origFromType = OptionalType::get(origFromType);
6751
6745
}
@@ -11401,7 +11395,8 @@ ConstraintSystem::simplifyRestrictedConstraint(
11401
11395
addFixConstraint(fix, matchKind, type1, type2, locator);
11402
11396
}
11403
11397
11404
- ConstraintRestrictions.push_back(std::make_tuple(type1, type2, restriction));
11398
+ ConstraintRestrictions.push_back(
11399
+ std::make_tuple(type1.getPointer(), type2.getPointer(), restriction));
11405
11400
return SolutionKind::Solved;
11406
11401
}
11407
11402
case SolutionKind::Unsolved:
0 commit comments