Skip to content

Commit ed745a5

Browse files
authored
Merge pull request #72142 from DougGregor/preinversegenerics-extensions
Allow @_preInverseGenerics on extensions
2 parents 66801fd + 3745b5a commit ed745a5

File tree

4 files changed

+12
-3
lines changed

4 files changed

+12
-3
lines changed

include/swift/AST/ASTMangler.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,9 @@ class ASTMangler : public Mangler {
479479
BaseEntitySignature(const Decl *decl);
480480
};
481481

482+
static bool inversesAllowed(const Decl *decl);
483+
static bool inversesAllowedIn(const DeclContext *ctx);
484+
482485
void appendContextOf(const ValueDecl *decl, BaseEntitySignature &base);
483486
void appendContextualInverses(const GenericTypeDecl *contextDecl,
484487
BaseEntitySignature &base,

include/swift/AST/DeclAttr.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ DECL_ATTR(_allowFeatureSuppression, AllowFeatureSuppression,
492492
OnAnyDecl | UserInaccessible | NotSerialized | ABIStableToAdd | APIStableToAdd | ABIStableToRemove | APIStableToRemove,
493493
157)
494494
SIMPLE_DECL_ATTR(_preInverseGenerics, PreInverseGenerics,
495-
OnAbstractFunction | OnSubscript | OnVar | UserInaccessible | ABIBreakingToAdd | ABIBreakingToRemove | APIStableToAdd | APIStableToRemove,
495+
OnAbstractFunction | OnSubscript | OnVar | OnExtension | UserInaccessible | ABIBreakingToAdd | ABIBreakingToRemove | APIStableToAdd | APIStableToRemove,
496496
158)
497497
LAST_DECL_ATTR(PreInverseGenerics)
498498

lib/AST/ASTMangler.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
using namespace swift;
6363
using namespace swift::Mangle;
6464

65-
static bool inversesAllowed(const Decl *decl) {
65+
bool ASTMangler::inversesAllowed(const Decl *decl) {
6666
if (!decl)
6767
return true;
6868

@@ -73,7 +73,7 @@ static bool inversesAllowed(const Decl *decl) {
7373
return !decl->getAttrs().hasAttribute<PreInverseGenericsAttr>();
7474
}
7575

76-
static bool inversesAllowedIn(const DeclContext *ctx) {
76+
bool ASTMangler::inversesAllowedIn(const DeclContext *ctx) {
7777
assert(ctx);
7878
return inversesAllowed(ctx->getInnermostDeclarationDeclContext());
7979
}
@@ -242,6 +242,9 @@ std::string ASTMangler::mangleConstructorVTableThunk(
242242
}
243243

244244
std::string ASTMangler::mangleWitnessTable(const RootProtocolConformance *C) {
245+
llvm::SaveAndRestore X(AllowInverses,
246+
inversesAllowedIn(C->getDeclContext()));
247+
245248
beginMangling();
246249
if (isa<NormalProtocolConformance>(C)) {
247250
appendProtocolConformance(C);

lib/IRGen/IRGenMangler.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,9 @@ IRGenMangler::mangleTypeForFlatUniqueTypeRef(CanGenericSignature sig,
197197

198198
std::string IRGenMangler::mangleProtocolConformanceDescriptor(
199199
const RootProtocolConformance *conformance) {
200+
llvm::SaveAndRestore X(AllowInverses,
201+
inversesAllowedIn(conformance->getDeclContext()));
202+
200203
beginMangling();
201204
if (isa<NormalProtocolConformance>(conformance)) {
202205
appendProtocolConformance(conformance);

0 commit comments

Comments
 (0)