Skip to content

Commit f1c5e07

Browse files
authored
Merge pull request #41920 from slavapestov/rqm-two-regression-tests
RequirementMachine: A couple of regression tests
2 parents 1f39f27 + f522e56 commit f1c5e07

File tree

2 files changed

+71
-0
lines changed

2 files changed

+71
-0
lines changed

test/Generics/rdar90506457.swift

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// RUN: %target-swift-frontend -typecheck %s -debug-generic-signatures -requirement-machine-protocol-signatures=on 2>&1 | %FileCheck %s
2+
3+
// CHECK-LABEL: .P1@
4+
// CHECK-NEXT: Requirement signature: <Self where Self.[P1]B : P2, Self.[P1]C : P4, Self.[P1]D : P5, Self.[P1]E : P6, Self.[P1]F : P3, Self.[P1]G == Self.[P1]B.[P2]G, Self.[P1]B.[P2]G == Self.[P1]C.[P4]G, Self.[P1]C.[P4]G == Self.[P1]D.[P5]G, Self.[P1]D.[P5]G == Self.[P1]E.[P6]G, Self.[P1]F.[Sequence]Element == SIMD2<Self.[P1]G>>
5+
public protocol P1 {
6+
associatedtype G
7+
associatedtype B: P2 where B.G == G
8+
associatedtype C: P4 where C.G == G
9+
associatedtype D: P5 where D.G == G
10+
associatedtype E: P6 where E.G == G
11+
associatedtype F: P3 where F.Element == SIMD2<G>
12+
}
13+
14+
// CHECK-LABEL: .P2@
15+
// CHECK-NEXT: Requirement signature: <Self where Self.[P2]A : P1, Self.[P2]C : P4, Self.[P2]D : P5, Self.[P2]E : P6, Self.[P2]G == Self.[P2]A.[P1]G, Self.[P2]A.[P1]G == Self.[P2]C.[P4]G, Self.[P2]C.[P4]G == Self.[P2]D.[P5]G, Self.[P2]D.[P5]G == Self.[P2]E.[P6]G>
16+
public protocol P2 {
17+
associatedtype G
18+
associatedtype A: P1 where A.G == G
19+
associatedtype C: P4 where C.G == G
20+
associatedtype D: P5 where D.G == G
21+
associatedtype E: P6 where E.G == G
22+
}
23+
24+
// CHECK-LABEL: .P3@
25+
// CHECK-NEXT: Requirement signature: <Self where Self : MutableCollection, Self : RandomAccessCollection, Self.[Collection]Index == Int>
26+
public protocol P3: RandomAccessCollection, MutableCollection where Index == Int {}
27+
28+
// CHECK-LABEL: .P4@
29+
// CHECK-NEXT: Requirement signature: <Self where Self.[P4]G : SIMDScalar>
30+
public protocol P4 {
31+
associatedtype G: SIMDScalar
32+
}
33+
34+
// CHECK-LABEL: .P5@
35+
// CHECK-NEXT: Requirement signature: <Self where Self.[P5]G : SIMDScalar>
36+
public protocol P5 {
37+
associatedtype G: SIMDScalar
38+
}
39+
40+
// CHECK-LABEL: .P6@
41+
// CHECK-NEXT: Requirement signature: <Self where Self.[P6]G : SIMDScalar>
42+
public protocol P6 {
43+
associatedtype G: SIMDScalar
44+
}

test/Generics/rdar90506460.swift

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// RUN: %target-swift-frontend -typecheck %s -debug-generic-signatures -requirement-machine-protocol-signatures=on 2>&1 | %FileCheck %s
2+
3+
// CHECK-LABEL: .P1@
4+
// CHECK-NEXT: Requirement signature: <Self where Self == Self.[P1]A.[P2]C, Self.[P1]A : P3, Self.[P1]B : P4, Self.[P1]A.[P2]C == Self.[P1]B.[P2]C>
5+
public protocol P1 {
6+
associatedtype A: P3 where A.C == Self
7+
associatedtype B: P4 where B.C == Self
8+
}
9+
10+
// CHECK-LABEL: .P2@
11+
// CHECK-NEXT: Requirement signature: <Self where Self : CaseIterable, Self : Hashable, Self : RawRepresentable, Self.[P2]C : P1, Self.[P2]D : P5, Self.[RawRepresentable]RawValue == String>
12+
public protocol P2: Hashable, RawRepresentable, CaseIterable where RawValue == String {
13+
associatedtype C: P1
14+
associatedtype D: P5
15+
}
16+
17+
// CHECK-LABEL: .P3@
18+
// CHECK-NEXT: Requirement signature: <Self where Self : P2>
19+
public protocol P3: P2 {}
20+
21+
// CHECK-LABEL: .P4@
22+
// CHECK-NEXT: Requirement signature: <Self where Self : P2>
23+
public protocol P4: P2 {}
24+
25+
// CHECK-LABEL: .P5@
26+
// CHECK-NEXT: Requirement signature: <Self where Self : CaseIterable, Self : Hashable, Self : RawRepresentable, Self.[RawRepresentable]RawValue == String>
27+
public protocol P5: Hashable, RawRepresentable, CaseIterable where RawValue == String {}

0 commit comments

Comments
 (0)