File tree Expand file tree Collapse file tree 3 files changed +59
-0
lines changed Expand file tree Collapse file tree 3 files changed +59
-0
lines changed Original file line number Diff line number Diff line change @@ -694,6 +694,7 @@ Property behaviors are implemented using private protocol conformances.
694
694
dependent-associated-conformance 'HA' DEPENDENT-CONFORMANCE-INDEX
695
695
696
696
dependent-associated-conformance ::= type protocol
697
+ dependent-protocol-conformance ::= dependent-protocol-conformance opaque-type 'HO'
697
698
698
699
A compact representation used to represent mangled protocol conformance witness
699
700
arguments at runtime. The ``module `` is only specified for conformances that
Original file line number Diff line number Diff line change @@ -2613,6 +2613,20 @@ void ASTMangler::appendConcreteProtocolConformance(
2613
2613
auto conformanceAccessPath =
2614
2614
CurGenericSignature->getConformanceAccessPath (type, proto);
2615
2615
appendDependentProtocolConformance (conformanceAccessPath);
2616
+ } else if (auto opaqueType = canType->getAs <OpaqueTypeArchetypeType>()) {
2617
+ GenericSignature *opaqueSignature = opaqueType->getBoundSignature ();
2618
+ GenericTypeParamType *opaqueTypeParam = opaqueSignature->getGenericParams ().back ();
2619
+ ConformanceAccessPath conformanceAccessPath =
2620
+ opaqueSignature->getConformanceAccessPath (opaqueTypeParam, proto);
2621
+
2622
+ // Append the conformance access path with the signature of the opaque type.
2623
+ CanGenericSignature savedSignature = CurGenericSignature;
2624
+ CurGenericSignature = opaqueSignature->getCanonicalSignature ();
2625
+ appendDependentProtocolConformance (conformanceAccessPath);
2626
+ CurGenericSignature = savedSignature;
2627
+
2628
+ appendType (canType);
2629
+ appendOperator (" HO" );
2616
2630
} else {
2617
2631
auto conditionalConf = module ->lookupConformance (canType, proto);
2618
2632
appendConcreteProtocolConformance (conditionalConf->getConcrete ());
Original file line number Diff line number Diff line change
1
+ // RUN: %empty-directory(%t)
2
+ // RUN: %target-build-swift -module-name=test %s -o %t/a.out
3
+ // RUN: %target-run %t/a.out | %FileCheck %s
4
+ // REQUIRES: executable_test
5
+ // REQUIRES: CPU=arm64 || CPU=x86_64
6
+
7
+ // Check that the IRGenMangler does not crashq when mangling a conformance
8
+ // access path with an opaque result type as root.
9
+ // As a bonus, also do a runtime test to check that there is no miscompile.
10
+
11
+ protocol P {
12
+ func get( ) -> Int
13
+ }
14
+
15
+ extension Int : P {
16
+ func get( ) -> Int {
17
+ return self
18
+ }
19
+ }
20
+
21
+ struct X < T> {
22
+ let tt : T
23
+ init ( _ t: T ) {
24
+ tt = t
25
+ }
26
+ }
27
+
28
+ extension X : P where T : P {
29
+ func get( ) -> Int {
30
+ return tt. get ( )
31
+ }
32
+ }
33
+
34
+ func bar( ) -> some P {
35
+ return 27
36
+ }
37
+
38
+ func foo( ) -> some P {
39
+ return X ( bar ( ) )
40
+ }
41
+
42
+ // CHECK: 27
43
+ print ( foo ( ) . get ( ) )
44
+
You can’t perform that action at this time.
0 commit comments