Skip to content

Commit f269cb5

Browse files
committed
Disable mangling of inverses for generalized existential shape symbols
1 parent 87e6ce7 commit f269cb5

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

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)