@@ -1795,16 +1795,21 @@ static ProtocolConformanceRef getBuiltinMetaTypeTypeConformance(
1795
1795
Type type, const AnyMetatypeType *metatypeType, ProtocolDecl *protocol) {
1796
1796
ASTContext &ctx = protocol->getASTContext();
1797
1797
1798
- // Only metatypes of Copyable types are Copyable.
1799
- if (protocol->isSpecificProtocol(KnownProtocolKind::Copyable) &&
1800
- !metatypeType->getInstanceType()->isNoncopyable()) {
1801
- return ProtocolConformanceRef(
1802
- ctx.getBuiltinConformance(type, protocol,
1803
- BuiltinConformanceKind::Synthesized));
1798
+ if (!ctx.LangOpts.hasFeature(swift::Feature::NoncopyableGenerics) &&
1799
+ protocol->isSpecificProtocol(KnownProtocolKind::Copyable)) {
1800
+ // Only metatypes of Copyable types are Copyable.
1801
+ if (metatypeType->getInstanceType()->isNoncopyable()) {
1802
+ return ProtocolConformanceRef::forMissingOrInvalid(type, protocol);
1803
+ } else {
1804
+ return ProtocolConformanceRef(
1805
+ ctx.getBuiltinConformance(type, protocol,
1806
+ BuiltinConformanceKind::Synthesized));
1807
+ }
1804
1808
}
1805
1809
1806
- // All metatypes are Sendable
1807
- if (protocol->isSpecificProtocol(KnownProtocolKind::Sendable)) {
1810
+ // All metatypes are Sendable and Copyable
1811
+ if (protocol->isSpecificProtocol(KnownProtocolKind::Sendable) ||
1812
+ protocol->isSpecificProtocol(KnownProtocolKind::Copyable)) {
1808
1813
return ProtocolConformanceRef(
1809
1814
ctx.getBuiltinConformance(type, protocol,
1810
1815
BuiltinConformanceKind::Synthesized));
@@ -1876,9 +1881,10 @@ LookupConformanceInModuleRequest::evaluate(
1876
1881
// constraint and the superclass conforms to the protocol.
1877
1882
if (auto archetype = type->getAs<ArchetypeType>()) {
1878
1883
1879
- // All archetypes conform to Copyable since they represent a generic.
1880
- if (protocol->isSpecificProtocol(KnownProtocolKind::Copyable))
1881
- return ProtocolConformanceRef(protocol);
1884
+ // Without noncopyable generics, all archetypes are Copyable
1885
+ if (!ctx.LangOpts.hasFeature(Feature::NoncopyableGenerics))
1886
+ if (protocol->isSpecificProtocol(KnownProtocolKind::Copyable))
1887
+ return ProtocolConformanceRef(protocol);
1882
1888
1883
1889
// The generic signature builder drops conformance requirements that are made
1884
1890
// redundant by a superclass requirement, so check for a concrete
@@ -2002,6 +2008,18 @@ LookupConformanceInModuleRequest::evaluate(
2002
2008
return ProtocolConformanceRef::forMissingOrInvalid(type, protocol);
2003
2009
}
2004
2010
} else if (protocol->isSpecificProtocol(KnownProtocolKind::Copyable)) {
2011
+
2012
+ if (!ctx.LangOpts.hasFeature(Feature::NoncopyableGenerics)) {
2013
+ // Return an abstract conformance to maintain legacy compatability.
2014
+ // We only need to do this until we are properly dealing with or
2015
+ // omitting Copyable conformances in modules/interfaces.
2016
+
2017
+ if (nominal->isNoncopyable())
2018
+ return ProtocolConformanceRef::forMissingOrInvalid(type, protocol);
2019
+ else
2020
+ return ProtocolConformanceRef(protocol);
2021
+ }
2022
+
2005
2023
// Try to infer Copyable conformance.
2006
2024
ImplicitKnownProtocolConformanceRequest
2007
2025
cvRequest{nominal, KnownProtocolKind::Copyable};
0 commit comments