describe how generic parameters implicitly require Copyable

This commit is contained in:
Kavon Farvardin
2023-06-23 20:14:22 -07:00
parent 66bf3c03fc
commit c40985dfb3
7 changed files with 139 additions and 61 deletions

View File

@@ -3832,11 +3832,11 @@ ConstraintSystem::matchExistentialTypes(Type type1, Type type2,
if (type1->getMetatypeInstanceType()->isPureMoveOnly()) {
// tailor error message
if (shouldAttemptFixes()) {
auto *fix =
MustBeCopyable::create(*this, type1,
{type2,
NoncopyableMatchFailure::CastToExistential},
getConstraintLocator(locator));
auto *fix = MustBeCopyable::create(*this,
type1,
NoncopyableMatchFailure::forExistentialCast(
type2),
getConstraintLocator(locator));
if (!recordFix(fix))
return getTypeMatchSuccess();
}
@@ -8495,7 +8495,10 @@ 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,
NoncopyableMatchFailure::forCopyableConstraint(),
getConstraintLocator(locator));
if (!recordFix(fix))
return SolutionKind::Solved;
}