Skip to content

Commit b414a93

Browse files
authored
Merge pull request swiftlang#72127 from DougGregor/mangle-generalized-ext-without-inverses
Disable mangling of inverses for generalized existential shape symbols
2 parents d113ea1 + f269cb5 commit b414a93

File tree

4 files changed

+22
-5
lines changed

4 files changed

+22
-5
lines changed

lib/AST/Requirement.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,8 +349,7 @@ void InverseRequirement::expandDefaults(
349349
ASTContext &ctx,
350350
ArrayRef<Type> gps,
351351
SmallVectorImpl<StructuralRequirement> &result) {
352-
if (!SWIFT_ENABLE_EXPERIMENTAL_NONCOPYABLE_GENERICS &&
353-
!ctx.LangOpts.hasFeature(Feature::NoncopyableGenerics))
352+
if (!ctx.LangOpts.hasFeature(Feature::NoncopyableGenerics))
354353
return;
355354

356355
for (auto gp : gps) {

lib/IRGen/IRGenMangler.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,11 @@ void
495495
IRGenMangler::appendExtendedExistentialTypeShape(CanGenericSignature genSig,
496496
CanType shapeType) {
497497
// Append the generalization signature.
498-
if (genSig) appendGenericSignature(genSig);
498+
if (genSig) {
499+
// Generalization signature never reference inverses.
500+
llvm::SaveAndRestore X(AllowInverses, false);
501+
appendGenericSignature(genSig);
502+
}
499503

500504
// Append the existential type.
501505
appendType(shapeType, genSig);

test/IRGen/existential_shape_metadata.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
// RUN: %target-swift-frontend -emit-ir %s -swift-version 5 -disable-availability-checking | %IRGenFileCheck %s
22

3-
// XFAIL: noncopyable_generics
4-
53
// CHECK-LABEL: @"$sl26existential_shape_metadata2Q0_px1TRts_XPXGMq" = linkonce_odr hidden constant
64
// CHECK-SAME: { i32 {{.*}}sub ([[INT]] ptrtoint (ptr @{{[0-9]+}} to [[INT]])
75
// CHECK-SAME: i32 6400,
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// RUN: %target-swift-frontend -emit-ir %s -swift-version 5 -disable-availability-checking -enable-experimental-feature NoncopyableGenerics -module-name existential_shape_metadata | %IRGenFileCheck %s
2+
3+
// NOTE: Once noncopyable generics are enabled by default, merge this back into existential_shape_metadata.swift
4+
5+
// CHECK: @"$sl26existential_shape_metadata3QNC_px1ARts_XPXGMq" = linkonce_odr
6+
7+
public protocol QNC<A>: ~Copyable {
8+
associatedtype A: ~Copyable
9+
}
10+
11+
public struct NCStruct: ~Copyable { }
12+
13+
14+
public func testNoncopyableConcrete() -> (Any & ~Copyable).Type {
15+
return (any QNC<NCStruct>).self
16+
}

0 commit comments

Comments
 (0)