File tree Expand file tree Collapse file tree 2 files changed +47
-1
lines changed Expand file tree Collapse file tree 2 files changed +47
-1
lines changed Original file line number Diff line number Diff line change @@ -303,7 +303,33 @@ class TypeMatcher {
303
303
TRIVIAL_CASE (SILFunctionType)
304
304
TRIVIAL_CASE (SILBlockStorageType)
305
305
TRIVIAL_CASE (SILBoxType)
306
- TRIVIAL_CASE (ProtocolCompositionType)
306
+
307
+ bool visitProtocolCompositionType (CanProtocolCompositionType firstProtocolComposition,
308
+ Type secondType,
309
+ Type sugaredFirstType) {
310
+ if (auto secondProtocolComposition = secondType->getAs <ProtocolCompositionType>()) {
311
+ auto firstMembers = firstProtocolComposition->getMembers ();
312
+ auto secondMembers = secondProtocolComposition->getMembers ();
313
+
314
+ if (firstMembers.size () == secondMembers.size ()) {
315
+ for (unsigned i : indices (firstMembers)) {
316
+ auto firstMember = firstMembers[i];
317
+ auto secondMember = secondMembers[i];
318
+
319
+ // FIXME: We lose sugar here, because the sugared type might have a different
320
+ // number of members, or the members might appear in a different order.
321
+ if (!this ->visit (CanType (firstMember), secondMember, firstMember)) {
322
+ return false ;
323
+ }
324
+ }
325
+
326
+ return true ;
327
+ }
328
+ }
329
+
330
+ return mismatch (firstProtocolComposition.getPointer (), secondType,
331
+ sugaredFirstType);
332
+ }
307
333
308
334
bool visitParameterizedProtocolType (CanParameterizedProtocolType firstParametrizedProto,
309
335
Type secondType,
Original file line number Diff line number Diff line change
1
+ // RUN: %target-swift-frontend -typecheck %s -debug-generic-signatures -requirement-machine-protocol-signatures=on 2>&1 | %FileCheck %s
2
+
3
+ class C < T> { }
4
+
5
+ protocol P0 { }
6
+
7
+ protocol P1 {
8
+ associatedtype T where T == C < U > & P0
9
+ associatedtype U
10
+ }
11
+
12
+ protocol P2 {
13
+ associatedtype T where T == C < Int > & P0
14
+ }
15
+
16
+ // CHECK-LABEL: .P3@
17
+ // CHECK-NEXT: Requirement signature: <Self where Self.[P3]T : P1, Self.[P3]T : P2>
18
+ protocol P3 {
19
+ associatedtype T : P1 & P2 where T. U == Int
20
+ }
You can’t perform that action at this time.
0 commit comments