Reapply: Collapse the three optional-to-optional restriction kinds.

This reapply's Doug's change d79ba781c6,
which had previously been applied on top of
1efafbcd9b, the latter of which resulted
in a source compatibility break.
This commit is contained in:
Mark Lacey
2017-01-15 22:15:47 -07:00
parent fc73e79b74
commit c301833e15
5 changed files with 3 additions and 19 deletions

View File

@@ -2009,13 +2009,13 @@ ConstraintSystem::matchTypes(Type type1, Type type2, ConstraintKind kind,
decl1 == TC.Context.getImplicitlyUnwrappedOptionalDecl()) {
assert(boundGenericType1->getGenericArgs().size() == 1);
conversionsOrFixes.push_back(
ConversionRestrictionKind::ImplicitlyUnwrappedOptionalToOptional);
ConversionRestrictionKind::OptionalToOptional);
} else if (optionalKind2 == OTK_ImplicitlyUnwrappedOptional &&
kind >= ConstraintKind::Conversion &&
decl1 == TC.Context.getOptionalDecl()) {
assert(boundGenericType1->getGenericArgs().size() == 1);
conversionsOrFixes.push_back(
ConversionRestrictionKind::OptionalToImplicitlyUnwrappedOptional);
ConversionRestrictionKind::OptionalToOptional);
}
}
@@ -3818,8 +3818,6 @@ ConstraintSystem::simplifyRestrictedConstraintImpl(
// T $< U ===> T! $< U?
// also:
// T <c U ===> T? <c U!
case ConversionRestrictionKind::OptionalToImplicitlyUnwrappedOptional:
case ConversionRestrictionKind::ImplicitlyUnwrappedOptionalToOptional:
case ConversionRestrictionKind::OptionalToOptional: {
addContextualScore();
assert(matchKind >= ConstraintKind::Subtype);