Merge pull request #83953 from Azoy/62-extended-existentials

[6.2] [AST & Runtime] Correctly mangle extended existentials with inverse requirements
This commit is contained in:
Alejandro Alonso
2025-08-30 11:10:21 -07:00
committed by GitHub
8 changed files with 154 additions and 58 deletions

View File

@@ -2352,12 +2352,7 @@ public:
}
bool isCopyable() const {
if (!hasGeneralizationSignature()) {
return true;
}
auto *reqts = getGenSigRequirements();
for (unsigned i = 0, e = getNumGenSigRequirements(); i < e; ++i) {
auto &reqt = reqts[i];
for (auto &reqt : getRequirementSignature().getRequirements()) {
if (reqt.getKind() != GenericRequirementKind::InvertedProtocols) {
continue;
}

View File

@@ -117,9 +117,24 @@ struct ExistentialLayout {
LayoutConstraint getLayoutConstraint() const;
/// Whether this layout has any inverses within its signature.
bool hasInverses() const {
return !inverses.empty();
}
/// Whether this existential needs to have an extended existential shape. This
/// is relevant for the mangler to mangle as a symbolic link where possible
/// and for IRGen directly emitting some existentials.
///
/// If 'allowInverses' is false, then regardless of if this existential layout
/// has inverse requirements those will not influence the need for having a
/// shape.
bool needsExtendedShape(bool allowInverses = true) const;
private:
SmallVector<ProtocolDecl *, 4> protocols;
SmallVector<ParameterizedProtocolType *, 4> parameterized;
InvertibleProtocolSet inverses;
};
}