mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Merge pull request #76572 from kubamracek/embedded-class-bound-existentials
[embedded] Introduce class-bound existentials into Embedded Swift
This commit is contained in:
@@ -89,9 +89,23 @@ inline bool isEmbedded(CanType t) {
|
||||
return t->getASTContext().LangOpts.hasFeature(Feature::Embedded);
|
||||
}
|
||||
|
||||
// Metadata is not generated and not allowed to be referenced in Embedded Swift,
|
||||
// expect for classes (both generic and non-generic), dynamic self, and
|
||||
// class-bound existentials.
|
||||
inline bool isMetadataAllowedInEmbedded(CanType t) {
|
||||
return isa<ClassType>(t) || isa<BoundGenericClassType>(t) ||
|
||||
isa<DynamicSelfType>(t);
|
||||
if (isa<ClassType>(t) || isa<BoundGenericClassType>(t) ||
|
||||
isa<DynamicSelfType>(t)) {
|
||||
return true;
|
||||
}
|
||||
if (auto existentialTy = dyn_cast<ExistentialType>(t)) {
|
||||
if (existentialTy->requiresClass())
|
||||
return true;
|
||||
}
|
||||
if (auto archeTy = dyn_cast<ArchetypeType>(t)) {
|
||||
if (archeTy->requiresClass())
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
inline bool isEmbedded(Decl *d) {
|
||||
@@ -1062,7 +1076,10 @@ public:
|
||||
}
|
||||
|
||||
static LinkEntity forProtocolWitnessTable(const RootProtocolConformance *C) {
|
||||
assert(!isEmbedded(C));
|
||||
if (isEmbedded(C)) {
|
||||
assert(C->getProtocol()->requiresClass());
|
||||
}
|
||||
|
||||
LinkEntity entity;
|
||||
entity.setForProtocolConformance(Kind::ProtocolWitnessTable, C);
|
||||
return entity;
|
||||
|
||||
@@ -54,6 +54,9 @@ enum class RuntimeEffect : unsigned {
|
||||
|
||||
/// Witness methods, boxing, unboxing, initializing, etc.
|
||||
Existential = 0x80,
|
||||
|
||||
/// Class-bound only existential
|
||||
ExistentialClassBound = 0x200,
|
||||
|
||||
/// Not modelled currently.
|
||||
Concurrency = 0x0,
|
||||
|
||||
Reference in New Issue
Block a user