mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
AST: Use a builtin conformance for unconditional Copyable/Escapable
This generalizes what we were already doing for classes.
This commit is contained in:
@@ -29,7 +29,6 @@
|
||||
#include "swift/AST/DiagnosticsSema.h"
|
||||
#include "swift/AST/ExistentialLayout.h"
|
||||
#include "swift/AST/GenericEnvironment.h"
|
||||
#include "swift/AST/InverseMarking.h"
|
||||
#include "swift/AST/NameLookup.h"
|
||||
#include "swift/AST/NameLookupRequests.h"
|
||||
#include "swift/AST/PackConformance.h"
|
||||
@@ -403,39 +402,6 @@ static ProtocolConformanceRef getBuiltinMetaTypeTypeConformance(
|
||||
return ProtocolConformanceRef::forMissingOrInvalid(type, protocol);
|
||||
}
|
||||
|
||||
static ProtocolConformanceRef
|
||||
getBuiltinInvertibleProtocolConformance(NominalTypeDecl *nominal,
|
||||
Type type,
|
||||
ProtocolDecl *protocol) {
|
||||
assert(isa<ClassDecl>(nominal));
|
||||
ASTContext &ctx = protocol->getASTContext();
|
||||
|
||||
auto ip = protocol->getInvertibleProtocolKind();
|
||||
switch (*ip) {
|
||||
case InvertibleProtocolKind::Copyable:
|
||||
// If move-only classes is enabled, we'll check the markings.
|
||||
if (ctx.LangOpts.hasFeature(Feature::MoveOnlyClasses)) {
|
||||
switch (nominal->hasInverseMarking(*ip).getKind()) {
|
||||
case InverseMarking::Kind::LegacyExplicit:
|
||||
case InverseMarking::Kind::Explicit:
|
||||
// An inverse ~Copyable prevents conformance.
|
||||
return ProtocolConformanceRef::forInvalid();
|
||||
|
||||
case InverseMarking::Kind::None:
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case InvertibleProtocolKind::Escapable:
|
||||
// Always conforms.
|
||||
break;
|
||||
}
|
||||
|
||||
return ProtocolConformanceRef(
|
||||
ctx.getBuiltinConformance(type, protocol,
|
||||
BuiltinConformanceKind::Synthesized));
|
||||
}
|
||||
|
||||
/// Synthesize a builtin type conformance to the given protocol, if
|
||||
/// appropriate.
|
||||
static ProtocolConformanceRef
|
||||
@@ -625,13 +591,6 @@ LookupConformanceInModuleRequest::evaluate(
|
||||
if (!nominal || isa<ProtocolDecl>(nominal))
|
||||
return ProtocolConformanceRef::forMissingOrInvalid(type, protocol);
|
||||
|
||||
// We specially avoid recording conformances to invertible protocols in a
|
||||
// class's conformance table. This prevents an evaluator cycle.
|
||||
if (ctx.LangOpts.hasFeature(Feature::NoncopyableGenerics)
|
||||
&& isa<ClassDecl>(nominal)
|
||||
&& protocol->getInvertibleProtocolKind())
|
||||
return getBuiltinInvertibleProtocolConformance(nominal, type, protocol);
|
||||
|
||||
// Expand conformances added by extension macros.
|
||||
//
|
||||
// FIXME: This expansion should only be done if the
|
||||
|
||||
Reference in New Issue
Block a user