1- // RUN: %target-typecheck-verify-swift
2- // RUN: %target-typecheck-verify-swift -debug-generic-signatures > %t.dump 2>&1
1+ // FIXME: Once the Requirement Machine can emit diagnostics, run this test with
2+ // it enabled unconditionally.
3+
4+ // RUN: %target-typecheck-verify-swift -requirement-machine-protocol-signatures=off
5+ // RUN: %target-swift-frontend -typecheck %s -debug-generic-signatures -requirement-machine-protocol-signatures=on > %t.dump 2>&1
36// RUN: %FileCheck %s < %t.dump
47
58
@@ -54,6 +57,9 @@ protocol Q3_1: P3, P3_1 {} // expected-error{{generic signature requires types '
5457
5558// Subprotocols can force associated types in their parents to be concrete, and
5659// this should be understood for types constrained by the subprotocols.
60+
61+ // CHECK-LABEL: .Q4@
62+ // CHECK: Requirement signature: <Self where Self : P, Self.[P]A == Int>
5763protocol Q4 : P {
5864 typealias A = Int // expected-warning{{typealias overriding associated type 'A' from protocol 'P'}}
5965}
@@ -70,22 +76,21 @@ func getP_X<T: P>(_: T.Type) -> T.X.Type { return T.X.self }
7076func checkQ4_A< T: Q4 > ( x: T . Type ) { sameType ( getP_A ( x) , Int . self) }
7177func checkQ4_X< T: Q4 > ( x: T . Type ) { sameType ( getP_X ( x) , Int . self) }
7278
73- // FIXME: these do not work, seemingly mainly due to the 'recursive decl validation'
74- // FIXME in GenericSignatureBuilder.cpp.
75- /*
7679func checkQ5_A< T: Q5 > ( x: T . Type ) { sameType ( getP_A ( x) , Int . self) }
7780func checkQ5_X< T: Q5 > ( x: T . Type ) { sameType ( getP_X ( x) , Int . self) }
78- */
7981
8082
81- // Typealiases happen to allow imposing same type requirements between parent
82- // protocols
83+
84+ // Typealiases allow imposing same type requirements between parent protocols
8385protocol P6_1 {
8486 associatedtype A // expected-note{{'A' declared here}}
8587}
8688protocol P6_2 {
8789 associatedtype B
8890}
91+
92+ // CHECK-LABEL: .Q6@
93+ // CHECK-NEXT: Requirement signature: <Self where Self : P6_1, Self : P6_2, Self.[P6_1]A == Self.[P6_2]B>
8994protocol Q6 : P6_1 , P6_2 {
9095 typealias A = B // expected-warning{{typealias overriding associated type}}
9196}
@@ -101,7 +106,10 @@ protocol P7 {
101106 typealias A = Int
102107}
103108
109+ // CHECK-LABEL: .P7a@
110+ // CHECK: Requirement signature: <Self where Self : P7>
104111protocol P7a : P7 {
105112 associatedtype A // expected-warning{{associated type 'A' is redundant with type 'A' declared in inherited protocol 'P7'}}
106113}
107114
115+ func testP7A< T : P7a > ( _: T , a: T . A ) -> Int { return a }
0 commit comments