mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Merge pull request #71371 from slavapestov/ncgenerics-fixes-3
Non-copyable generics fixes, part 3
This commit is contained in:
@@ -3889,19 +3889,21 @@ ConstraintSystem::matchExistentialTypes(Type type1, Type type2,
|
||||
return getTypeMatchAmbiguous();
|
||||
}
|
||||
|
||||
// move-only types (and their metatypes) cannot match with existential types.
|
||||
if (type1->getMetatypeInstanceType()->isNoncopyable()) {
|
||||
// tailor error message
|
||||
if (shouldAttemptFixes()) {
|
||||
auto *fix = MustBeCopyable::create(*this,
|
||||
type1,
|
||||
NoncopyableMatchFailure::forExistentialCast(
|
||||
type2),
|
||||
getConstraintLocator(locator));
|
||||
if (!recordFix(fix))
|
||||
return getTypeMatchSuccess();
|
||||
if (!SWIFT_ENABLE_EXPERIMENTAL_NONCOPYABLE_GENERICS) {
|
||||
// move-only types (and their metatypes) cannot match with existential types.
|
||||
if (type1->getMetatypeInstanceType()->isNoncopyable()) {
|
||||
// tailor error message
|
||||
if (shouldAttemptFixes()) {
|
||||
auto *fix = MustBeCopyable::create(*this,
|
||||
type1,
|
||||
NoncopyableMatchFailure::forExistentialCast(
|
||||
type2),
|
||||
getConstraintLocator(locator));
|
||||
if (!recordFix(fix))
|
||||
return getTypeMatchSuccess();
|
||||
}
|
||||
return getTypeMatchFailure(locator);
|
||||
}
|
||||
return getTypeMatchFailure(locator);
|
||||
}
|
||||
|
||||
// FIXME: Feels like a hack.
|
||||
|
||||
Reference in New Issue
Block a user