Skip to content

Commit a9cb0ba

Browse files
committed
allow Copyable only in stdlib, with warning
1 parent d1a86dd commit a9cb0ba

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

lib/Sema/TypeCheckType.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4181,14 +4181,21 @@ TypeResolver::resolveDeclRefTypeRepr(DeclRefTypeRepr *repr,
41814181
return ErrorType::get(getASTContext());
41824182
}
41834183

4184-
// Do not allow unsuppressed uses of Copyable anywhere.
4184+
// Do not allow unsuppressed uses of Copyable.
41854185
if (!options.contains(TypeResolutionFlags::IsSuppressed)) {
41864186
if (auto protoTy = result->getAs<ProtocolType>()) {
41874187
if (auto protoDecl = protoTy->getDecl()) {
41884188
if (protoDecl->isSpecificProtocol(KnownProtocolKind::Copyable)) {
4189-
diagnose(repr->getLoc(), diag::copyable_only_suppression);
4190-
repr->setInvalid();
4191-
return ErrorType::get(getASTContext());
4189+
auto diag = diagnose(repr->getLoc(), diag::copyable_only_suppression);
4190+
// Make a special exception for the stdlib in the form of a warning
4191+
// rather than an error. We need this temporarily to help with the
4192+
// transition of _Copyable to Copyable.
4193+
if (resolution.getDeclContext()->getParentModule()->isStdlibModule()) {
4194+
diag.limitBehavior(DiagnosticBehavior::Warning);
4195+
} else {
4196+
repr->setInvalid();
4197+
return ErrorType::get(getASTContext());
4198+
}
41924199
}
41934200
}
41944201
}

0 commit comments

Comments
 (0)