@@ -3902,9 +3902,8 @@ bool ConstraintSystem::repairFailures(
39023902 // If the result type of the coercion has an value to optional conversion
39033903 // we can instead suggest the conditional downcast as it is safer in
39043904 // 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) {
39083907 ConversionRestrictionKind restrictionKind;
39093908 Type type1, type2;
39103909 std::tie (type1, type2, restrictionKind) = restriction;
@@ -6710,8 +6709,7 @@ static ConstraintFix *maybeWarnAboutExtraneousCast(
67106709 ConstraintSystem &cs, Type origFromType, Type origToType, Type fromType,
67116710 Type toType, SmallVector<Type, 4 > fromOptionals,
67126711 SmallVector<Type, 4 > toOptionals,
6713- const std::vector<std::tuple<Type, Type, ConversionRestrictionKind>>
6714- &constraintRestrictions,
6712+ const std::vector<ConversionRestriction> &constraintRestrictions,
67156713 ConstraintSystem::TypeMatchOptions flags,
67166714 ConstraintLocatorBuilder locator) {
67176715
@@ -6738,14 +6736,10 @@ static ConstraintFix *maybeWarnAboutExtraneousCast(
67386736 // "from" expression could be a type variable with value-to-optional
67396737 // restrictions that we have to account for optionality mismatch.
67406738 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))) {
67496743 extraOptionals++;
67506744 origFromType = OptionalType::get (origFromType);
67516745 }
@@ -11401,7 +11395,8 @@ ConstraintSystem::simplifyRestrictedConstraint(
1140111395 addFixConstraint (fix, matchKind, type1, type2, locator);
1140211396 }
1140311397
11404- ConstraintRestrictions.push_back (std::make_tuple (type1, type2, restriction));
11398+ ConstraintRestrictions.push_back (
11399+ std::make_tuple (type1.getPointer (), type2.getPointer (), restriction));
1140511400 return SolutionKind::Solved;
1140611401 }
1140711402 case SolutionKind::Unsolved:
0 commit comments