Skip to content

Commit 2441e68

Browse files
committed
Pass -requirement-machine-protocol-signatures=on in a few tests where the GSB got it wrong
These fail with -requirement-machine-protocol-signatures=verify because the GSB produces incorrect output. Enable the requirement machine unconditionally for these tests, bypassing verification. A new file test/Generics/same_type_requirements_in_protocol.swift contains reduced versions of all of the failures, with FileCheck used to confirm the exact requirement signature output.
1 parent 1747951 commit 2441e68

File tree

6 files changed

+81
-14
lines changed

6 files changed

+81
-14
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
// RUN: %target-swift-frontend -typecheck %s -requirement-machine-protocol-signatures=on -debug-generic-signatures 2>&1 | %FileCheck %s
2+
3+
// CHECK-LABEL: same_type_requirements_in_protocol.(file).P1@
4+
// CHECK-NEXT: Requirement signature: <Self where Self.X : P3, Self.X == Self.Y.X, Self.Y : P2>
5+
public protocol P1 {
6+
associatedtype X: P3
7+
associatedtype Y: P2 where Y.X == X
8+
}
9+
10+
// CHECK-LABEL: same_type_requirements_in_protocol.(file).P2@
11+
// CHECK-NEXT: Requirement signature: <Self where Self : P1>
12+
public protocol P2 : P1 {}
13+
14+
// CHECK-LABEL: same_type_requirements_in_protocol.(file).P3@
15+
// CHECK-NEXT: Requirement signature: <Self where Self == Self.Z.X, Self.Z : P2>
16+
public protocol P3 {
17+
associatedtype Z: P2 where Z.X == Self
18+
}
19+
20+
// CHECK-LABEL: same_type_requirements_in_protocol.(file).Q1@
21+
// CHECK-NEXT: Requirement signature: <Self>
22+
public protocol Q1 {
23+
associatedtype X
24+
associatedtype Y
25+
}
26+
27+
// CHECK-LABEL: same_type_requirements_in_protocol.(file).Q2@
28+
// CHECK-NEXT: Requirement signature: <Self where Self == Self.Z.B, Self.Z : Q3>
29+
public protocol Q2 {
30+
associatedtype Y
31+
associatedtype Z: Q3 where Z.B == Self
32+
}
33+
34+
// CHECK-LABEL: same_type_requirements_in_protocol.(file).Q3@
35+
// CHECK-NEXT: Requirement signature: <Self where Self.A : Q2, Self.B : Q1, Self.A.Y == Self.B.Y>
36+
public protocol Q3 {
37+
associatedtype A: Q2
38+
associatedtype B: Q1 where A.Y == B.Y
39+
}
40+
41+
// CHECK-LABEL: same_type_requirements_in_protocol.(file).R1@
42+
// CHECK-NEXT: Requirement signature: <Self where Self.B : R1>
43+
protocol R1 {
44+
associatedtype A
45+
associatedtype B : R1
46+
}
47+
48+
// CHECK-LABEL: same_type_requirements_in_protocol.(file).R2@
49+
// CHECK-NEXT: Requirement signature: <Self>
50+
protocol R2 {
51+
associatedtype C
52+
}
53+
54+
// CHECK-LABEL: same_type_requirements_in_protocol.(file).R3@
55+
// CHECK-NEXT: Requirement signature: <Self where Self : R1, Self : R2, Self.A == Self.C, Self.B : R3, Self.C == Self.B.A>
56+
protocol R3 : R1, R2 where B : R3, A == B.A, C == A {}
57+
58+
59+
// CHECK-LABEL: same_type_requirements_in_protocol.(file).S1@
60+
// CHECK-NEXT: Requirement signature: <Self>
61+
protocol S1 {}
62+
63+
// CHECK-LABEL: same_type_requirements_in_protocol.(file).S2@
64+
// CHECK-NEXT: Requirement signature: <Self where Self.X : S1, Self.X == Self.Y.X, Self.Y : S2>
65+
protocol S2 {
66+
associatedtype X : S1
67+
associatedtype Y: S2 where Y.X == X
68+
}

test/Generics/sr14510.swift

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// RUN: %target-typecheck-verify-swift
2-
// RUN: %target-swift-frontend -debug-generic-signatures -typecheck %s 2>&1 | %FileCheck %s
1+
// RUN: %target-typecheck-verify-swift -requirement-machine-protocol-signatures=off
2+
// RUN: %target-swift-frontend -debug-generic-signatures -typecheck %s -requirement-machine-protocol-signatures=on 2>&1 | %FileCheck %s
33

44
// CHECK-LABEL: Requirement signature: <Self where Self == Self.Dual.Dual, Self.Dual : Adjoint>
55
public protocol Adjoint {
@@ -21,11 +21,8 @@ where Self.Patch: Adjoint, Self.Dual: AdjointDiffable,
2121
// conformance requirements 'A : P', 'B : P' or 'C : P' can be dropped and
2222
// proven from the other two, but dropping two or more conformance requirements
2323
// leaves us with an invalid signature.
24-
//
25-
// Note that this minimization is still not quite correct; the requirement
26-
// 'Self.B.C == Self.A.A.A' is unnecessary.
2724

28-
// CHECK-LABEL: Requirement signature: <Self where Self.A : P, Self.A == Self.B.C, Self.B : P, Self.B == Self.A.C, Self.C == Self.A.B, Self.B.C == Self.A.A.A>
25+
// CHECK-LABEL: Requirement signature: <Self where Self.A : P, Self.A == Self.B.C, Self.B : P, Self.B == Self.A.C, Self.C == Self.A.B>
2926
protocol P {
3027
associatedtype A : P where A == B.C
3128
associatedtype B : P where B == A.C

test/Interpreter/polymorphic_builtins.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,20 @@
77

88
// RUN: %empty-directory(%t)
99

10-
// RUN: %target-build-swift-dylib(%t/%target-library-name(mysimd)) -enable-library-evolution %S/../Inputs/polymorphic_builtins.swift -emit-module -emit-module-path %t/mysimd.swiftmodule -module-name mysimd -parse-stdlib -D DEBUG -Onone
10+
// RUN: %target-build-swift-dylib(%t/%target-library-name(mysimd)) -enable-library-evolution %S/../Inputs/polymorphic_builtins.swift -emit-module -emit-module-path %t/mysimd.swiftmodule -module-name mysimd -parse-stdlib -D DEBUG -Onone -Xfrontend -requirement-machine-protocol-signatures=on
1111
// RUN: %target-codesign %t/%target-library-name(mysimd)
1212

13-
// RUN: %target-build-swift %s -L %t -I %t -lmysimd -parse-stdlib -Xfrontend -disable-access-control -Xfrontend -sil-verify-all %target-rpath(%t) -o %t/a.out -D DEBUG -Onone
13+
// RUN: %target-build-swift %s -L %t -I %t -lmysimd -parse-stdlib -Xfrontend -disable-access-control -Xfrontend -sil-verify-all %target-rpath(%t) -o %t/a.out -D DEBUG -Onone -Xfrontend -requirement-machine-protocol-signatures=on
1414
// RUN: %target-codesign %t/a.out
1515

1616
// RUN: %target-run %t/a.out %t/%target-library-name(mysimd)
1717

1818
// RUN: %empty-directory(%t)
1919

20-
// RUN: %target-build-swift-dylib(%t/%target-library-name(mysimd)) -enable-library-evolution %S/../Inputs/polymorphic_builtins.swift -emit-module -emit-module-path %t/mysimd.swiftmodule -module-name mysimd -parse-stdlib -O
20+
// RUN: %target-build-swift-dylib(%t/%target-library-name(mysimd)) -enable-library-evolution %S/../Inputs/polymorphic_builtins.swift -emit-module -emit-module-path %t/mysimd.swiftmodule -module-name mysimd -parse-stdlib -O -Xfrontend -requirement-machine-protocol-signatures=on
2121
// RUN: %target-codesign %t/%target-library-name(mysimd)
2222

23-
// RUN: %target-build-swift %s -L %t -I %t -lmysimd -parse-stdlib -Xfrontend -disable-access-control -Xfrontend -sil-verify-all %target-rpath(%t) -o %t/a.out -O
23+
// RUN: %target-build-swift %s -L %t -I %t -lmysimd -parse-stdlib -Xfrontend -disable-access-control -Xfrontend -sil-verify-all %target-rpath(%t) -o %t/a.out -O -Xfrontend -requirement-machine-protocol-signatures=on
2424
// RUN: %target-codesign %t/a.out
2525

2626
// RUN: %target-run %t/a.out %t/%target-library-name(mysimd)

test/decl/protocol/recursive_requirement_ok.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// RUN: %target-typecheck-verify-swift
2-
// RUN: %target-typecheck-verify-swift -debug-generic-signatures > %t.dump 2>&1
1+
// RUN: %target-typecheck-verify-swift -requirement-machine-protocol-signatures=on
2+
// RUN: %target-typecheck-verify-swift -requirement-machine-protocol-signatures=on -debug-generic-signatures > %t.dump 2>&1
33
// RUN: %FileCheck %s < %t.dump
44

55
protocol P {
@@ -88,6 +88,8 @@ protocol P11 {
8888
// Redundances within a requirement signature.
8989
protocol P12 { }
9090

91+
// CHECK-LABEL: .P13@
92+
// CHECK: Requirement signature: <Self where Self.AT1 : P12, Self.AT1 == Self.AT2.AT1, Self.AT2 : P13>
9193
protocol P13 {
9294
associatedtype AT1 : P12
9395
associatedtype AT2: P13 where AT2.AT1 == AT1

validation-test/compiler_crashers_2_fixed/0182-rdar45680857.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-swift-frontend -emit-ir %s
1+
// RUN: %target-swift-frontend -emit-ir %s -requirement-machine-protocol-signatures=on
22

33
public protocol Graph: class, Collection {
44
associatedtype V

validation-test/compiler_crashers_2_fixed/0192-rdar39826863.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-swift-frontend -typecheck %s
1+
// RUN: %target-swift-frontend -emit-ir %s -requirement-machine-protocol-signatures=on
22

33
protocol Tuple {
44
associatedtype Head

0 commit comments

Comments
 (0)