describe illegal casts to existentials

This commit is contained in:
Kavon Farvardin
2023-06-22 22:47:42 -07:00
parent ada0d335b1
commit 66bf3c03fc
8 changed files with 99 additions and 40 deletions

View File

@@ -3832,8 +3832,11 @@ ConstraintSystem::matchExistentialTypes(Type type1, Type type2,
if (type1->getMetatypeInstanceType()->isPureMoveOnly()) {
// tailor error message
if (shouldAttemptFixes()) {
auto *fix = MustBeCopyable::create(*this, type1,
getConstraintLocator(locator));
auto *fix =
MustBeCopyable::create(*this, type1,
{type2,
NoncopyableMatchFailure::CastToExistential},
getConstraintLocator(locator));
if (!recordFix(fix))
return getTypeMatchSuccess();
}
@@ -8492,7 +8495,7 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyConformsToConstraint(
// If this is a failure to conform to Copyable, tailor the error message.
if (protocol->isSpecificProtocol(KnownProtocolKind::Copyable)) {
auto *fix =
MustBeCopyable::create(*this, type, getConstraintLocator(locator));
MustBeCopyable::create(*this, type, {}, getConstraintLocator(locator));
if (!recordFix(fix))
return SolutionKind::Solved;
}