Skip to content

Commit ed75273

Browse files
committed
ASTMangler: Use the right generic signature when mangling conformance access path components
Only the first component is written in terms of the original generic signature; subsequent components are written in terms of their protocol's generic signature, <T where T : P>.
1 parent 51231e4 commit ed75273

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

lib/AST/ASTMangler.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3153,6 +3153,7 @@ void ASTMangler::appendDependentProtocolConformance(
31533153
// are.
31543154
SWIFT_DEFER {
31553155
currentProtocol = entry.second;
3156+
sig = currentProtocol->getGenericSignature();
31563157
};
31573158

31583159
// The first entry is the "root". Find this requirement in the generic
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
public protocol P {
2+
associatedtype T
3+
}
4+
5+
public protocol Q {
6+
associatedtype U
7+
}
8+
9+
public protocol R {
10+
associatedtype U : Q where U.U : P
11+
}
12+
13+
public struct G<T> {}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %target-swift-frontend -emit-module %S/Inputs/mangle_conformance_access_path_helper.swift -emit-module-path %t/mangle_conformance_access_path_helper.swiftmodule
3+
// RUN: %target-swift-frontend -emit-silgen %s -I %t -requirement-machine=verify | %FileCheck %s
4+
5+
import mangle_conformance_access_path_helper
6+
7+
struct GG<T : P> {}
8+
9+
// This is a retroactive conformance.
10+
extension G : P where T : P {}
11+
12+
// The mangling of GG<G<_>> will contain a conformance access path
13+
// for (Y.U.U : P). This path is (Y : R)(Self.U.U : P). The 'Self.U.U'
14+
// uses the short mangling if 'Self.U' only conforms to a single
15+
// protocol. However, this check was being performed in the original
16+
// generic signature <X, Y where Y : R>, and not the generic signature
17+
// for the protocol R, which is <Self where Self : R>.
18+
19+
// CHECK-LABEL: sil hidden [ossa] @$s30mangle_conformance_access_path3fooyyAA2GGVy0a1_b1_c1_D7_helper1GVy1U_AHQY_GAjE1PAAq_AE1RHD1_AH_AHQZAeKHA2__HCg_G_xq_tAeLR_r0_lF : $@convention(thin) <X, Y where Y : R> (GG<G<Y.U.U>>, @in_guaranteed X, @in_guaranteed Y) -> ()
20+
func foo<X, Y : R>(_: GG<G<Y.U.U>>, _: X, _: Y) {}

0 commit comments

Comments
 (0)