@@ -3973,10 +3973,10 @@ bool ConstraintSystem::repairFailures(
3973
3973
// we can instead suggest the conditional downcast as it is safer in
3974
3974
// situations like conditional binding.
3975
3975
auto useConditionalCast =
3976
- llvm::any_of (ConstraintRestrictions, [&](auto &restriction) {
3977
- ConversionRestrictionKind restrictionKind;
3976
+ llvm::any_of (ConstraintRestrictions, [&](const auto &restriction) {
3978
3977
Type type1, type2;
3979
- std::tie (type1, type2, restrictionKind) = restriction;
3978
+ std::tie (type1, type2) = restriction.first ;
3979
+ auto restrictionKind = restriction.second ;
3980
3980
3981
3981
if (restrictionKind != ConversionRestrictionKind::ValueToOptional)
3982
3982
return false ;
@@ -6770,7 +6770,6 @@ static ConstraintFix *maybeWarnAboutExtraneousCast(
6770
6770
ConstraintSystem &cs, Type origFromType, Type origToType, Type fromType,
6771
6771
Type toType, SmallVector<Type, 4 > fromOptionals,
6772
6772
SmallVector<Type, 4 > toOptionals,
6773
- const std::vector<ConversionRestriction> &constraintRestrictions,
6774
6773
ConstraintSystem::TypeMatchOptions flags,
6775
6774
ConstraintLocatorBuilder locator) {
6776
6775
@@ -6797,10 +6796,8 @@ static ConstraintFix *maybeWarnAboutExtraneousCast(
6797
6796
// "from" expression could be a type variable with value-to-optional
6798
6797
// restrictions that we have to account for optionality mismatch.
6799
6798
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)) {
6804
6801
extraOptionals++;
6805
6802
origFromType = OptionalType::get (origFromType);
6806
6803
}
@@ -6960,7 +6957,7 @@ ConstraintSystem::simplifyCheckedCastConstraint(
6960
6957
6961
6958
if (auto *fix = maybeWarnAboutExtraneousCast (
6962
6959
*this , origFromType, origToType, fromType, toType, fromOptionals,
6963
- toOptionals, ConstraintRestrictions, flags, locator)) {
6960
+ toOptionals, flags, locator)) {
6964
6961
(void )recordFix (fix);
6965
6962
}
6966
6963
};
@@ -7028,7 +7025,7 @@ ConstraintSystem::simplifyCheckedCastConstraint(
7028
7025
// succeed or fail.
7029
7026
if (auto *fix = maybeWarnAboutExtraneousCast (
7030
7027
*this , origFromType, origToType, fromType, toType, fromOptionals,
7031
- toOptionals, ConstraintRestrictions, flags, locator)) {
7028
+ toOptionals, flags, locator)) {
7032
7029
(void )recordFix (fix);
7033
7030
}
7034
7031
@@ -11358,8 +11355,8 @@ ConstraintSystem::simplifyRestrictedConstraint(
11358
11355
addFixConstraint (fix, matchKind, type1, type2, locator);
11359
11356
}
11360
11357
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} );
11363
11360
return SolutionKind::Solved;
11364
11361
}
11365
11362
case SolutionKind::Unsolved:
0 commit comments