Skip to content

Commit d737239

Browse files
committed
AST: Move TypeBase::isSendableType() to ConformanceLookup.cpp
1 parent d981cf3 commit d737239

File tree

2 files changed

+32
-24
lines changed

2 files changed

+32
-24
lines changed

lib/AST/ConformanceLookup.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -752,6 +752,38 @@ ModuleDecl::checkConformance(Type type, ProtocolDecl *proto,
752752
return lookupResult;
753753
}
754754

755+
///
756+
/// Sendable checking utility
757+
///
758+
759+
bool TypeBase::isSendableType() {
760+
auto proto = getASTContext().getProtocol(KnownProtocolKind::Sendable);
761+
if (!proto)
762+
return true;
763+
764+
// First check if we have a function type. If we do, check if it is
765+
// Sendable. We do this since functions cannot conform to protocols.
766+
if (auto *fas = getAs<SILFunctionType>())
767+
return fas->isSendable();
768+
if (auto *fas = getAs<AnyFunctionType>())
769+
return fas->isSendable();
770+
771+
auto conformance = proto->getParentModule()->checkConformance(this, proto);
772+
if (conformance.isInvalid())
773+
return false;
774+
775+
// Look for missing Sendable conformances.
776+
return !conformance.forEachMissingConformance(
777+
[](BuiltinProtocolConformance *missing) {
778+
return missing->getProtocol()->isSpecificProtocol(
779+
KnownProtocolKind::Sendable);
780+
});
781+
}
782+
783+
///
784+
/// Copyable and Escapable checking utilities
785+
///
786+
755787
/// Returns true if this type is _always_ Copyable using the legacy check
756788
/// that does not rely on conformances.
757789
static bool alwaysNoncopyable(Type ty) {

lib/AST/Type.cpp

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -513,30 +513,6 @@ bool TypeBase::isAnyActorType() {
513513
return false;
514514
}
515515

516-
bool TypeBase::isSendableType() {
517-
auto proto = getASTContext().getProtocol(KnownProtocolKind::Sendable);
518-
if (!proto)
519-
return true;
520-
521-
// First check if we have a function type. If we do, check if it is
522-
// Sendable. We do this since functions cannot conform to protocols.
523-
if (auto *fas = getAs<SILFunctionType>())
524-
return fas->isSendable();
525-
if (auto *fas = getAs<AnyFunctionType>())
526-
return fas->isSendable();
527-
528-
auto conformance = proto->getParentModule()->checkConformance(this, proto);
529-
if (conformance.isInvalid())
530-
return false;
531-
532-
// Look for missing Sendable conformances.
533-
return !conformance.forEachMissingConformance(
534-
[](BuiltinProtocolConformance *missing) {
535-
return missing->getProtocol()->isSpecificProtocol(
536-
KnownProtocolKind::Sendable);
537-
});
538-
}
539-
540516
bool TypeBase::isDistributedActor() {
541517
if (auto actor = getAnyActor())
542518
return actor->isDistributedActor();

0 commit comments

Comments
 (0)