Skip to content

Commit 4d982f3

Browse files
[CSSimplify] Do not record fix to coerce with existential restriction
1 parent fc49af2 commit 4d982f3

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2200,7 +2200,8 @@ ConstraintSystem::matchExistentialTypes(Type type1, Type type2,
22002200
}
22012201
} else { // There are no elements in the path
22022202
auto *anchor = locator.getAnchor();
2203-
if (!(anchor && isa<AssignExpr>(anchor)))
2203+
if (!(anchor &&
2204+
(isa<AssignExpr>(anchor) || isa<CoerceExpr>(anchor))))
22042205
return getTypeMatchFailure(locator);
22052206
}
22062207

@@ -2839,13 +2840,17 @@ bool ConstraintSystem::repairFailures(
28392840
conversionsOrFixes.push_back(coerceToCheckCastFix);
28402841
return true;
28412842
}
2842-
2843+
28432844
// If it has a deep equality restriction, defer the diagnostic to
28442845
// GenericMismatch.
28452846
if (hasConversionOrRestriction(ConversionRestrictionKind::DeepEquality) &&
2846-
!lhs->getOptionalObjectType() && !rhs->getOptionalObjectType()) {
2847-
return false;
2847+
!hasConversionOrRestriction(
2848+
ConversionRestrictionKind::OptionalToOptional)) {
2849+
return false;
28482850
}
2851+
2852+
if (hasConversionOrRestriction(ConversionRestrictionKind::Existential))
2853+
return false;
28492854

28502855
auto *fix = ContextualMismatch::create(*this, lhs, rhs,
28512856
getConstraintLocator(locator));

0 commit comments

Comments
 (0)