@@ -3973,10 +3973,10 @@ bool ConstraintSystem::repairFailures(
39733973 // we can instead suggest the conditional downcast as it is safer in
39743974 // situations like conditional binding.
39753975 auto useConditionalCast =
3976- llvm::any_of (ConstraintRestrictions, [&](auto &restriction) {
3977- ConversionRestrictionKind restrictionKind;
3976+ llvm::any_of (ConstraintRestrictions, [&](const auto &restriction) {
39783977 Type type1, type2;
3979- std::tie (type1, type2, restrictionKind) = restriction;
3978+ std::tie (type1, type2) = restriction.first ;
3979+ auto restrictionKind = restriction.second ;
39803980
39813981 if (restrictionKind != ConversionRestrictionKind::ValueToOptional)
39823982 return false ;
@@ -6770,7 +6770,6 @@ static ConstraintFix *maybeWarnAboutExtraneousCast(
67706770 ConstraintSystem &cs, Type origFromType, Type origToType, Type fromType,
67716771 Type toType, SmallVector<Type, 4 > fromOptionals,
67726772 SmallVector<Type, 4 > toOptionals,
6773- const std::vector<ConversionRestriction> &constraintRestrictions,
67746773 ConstraintSystem::TypeMatchOptions flags,
67756774 ConstraintLocatorBuilder locator) {
67766775
@@ -6797,10 +6796,8 @@ static ConstraintFix *maybeWarnAboutExtraneousCast(
67976796 // "from" expression could be a type variable with value-to-optional
67986797 // restrictions that we have to account for optionality mismatch.
67996798 const auto subExprType = cs.getType (castExpr->getSubExpr ());
6800- if (llvm::is_contained (
6801- constraintRestrictions,
6802- std::make_tuple (fromType.getPointer (), subExprType.getPointer (),
6803- ConversionRestrictionKind::ValueToOptional))) {
6799+ if (cs.hasConversionRestriction (fromType, subExprType,
6800+ ConversionRestrictionKind::ValueToOptional)) {
68046801 extraOptionals++;
68056802 origFromType = OptionalType::get (origFromType);
68066803 }
@@ -6960,7 +6957,7 @@ ConstraintSystem::simplifyCheckedCastConstraint(
69606957
69616958 if (auto *fix = maybeWarnAboutExtraneousCast (
69626959 *this , origFromType, origToType, fromType, toType, fromOptionals,
6963- toOptionals, ConstraintRestrictions, flags, locator)) {
6960+ toOptionals, flags, locator)) {
69646961 (void )recordFix (fix);
69656962 }
69666963 };
@@ -7028,7 +7025,7 @@ ConstraintSystem::simplifyCheckedCastConstraint(
70287025 // succeed or fail.
70297026 if (auto *fix = maybeWarnAboutExtraneousCast (
70307027 *this , origFromType, origToType, fromType, toType, fromOptionals,
7031- toOptionals, ConstraintRestrictions, flags, locator)) {
7028+ toOptionals, flags, locator)) {
70327029 (void )recordFix (fix);
70337030 }
70347031
@@ -11358,8 +11355,8 @@ ConstraintSystem::simplifyRestrictedConstraint(
1135811355 addFixConstraint (fix, matchKind, type1, type2, locator);
1135911356 }
1136011357
11361- ConstraintRestrictions.push_back (
11362- std::make_tuple (type1.getPointer (), type2.getPointer (), restriction) );
11358+ ConstraintRestrictions.insert ({
11359+ std::make_pair (type1.getPointer (), type2.getPointer ()) , restriction} );
1136311360 return SolutionKind::Solved;
1136411361 }
1136511362 case SolutionKind::Unsolved:
0 commit comments