1- // RUN: %target-typecheck-verify-swift
1+ // RUN: %target-typecheck-verify-swift -requirement-machine-inferred-signatures=verify
22
33protocol SomeProtocol {
44 associatedtype T
55}
66
77extension SomeProtocol where T == Optional < T > { } // expected-error{{same-type constraint 'Self.T' == 'Optional<Self.T>' is recursive}}
8+ // expected-error@-1 {{cannot build rewrite system for generic signature; concrete nesting limit exceeded}}
9+ // expected-note@-2 {{failed rewrite rule is τ_0_0.[SomeProtocol:T].[concrete: Optional<Optional<Optional<Optional<Optional<Optional<Optional<Optional<Optional<Optional<Optional<Optional<Optional<Optional<Optional<Optional<Optional<Optional<Optional<Optional<Optional<Optional<Optional<Optional<Optional<Optional<Optional<Optional<Optional<Optional<τ_0_0.[SomeProtocol:T]>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>] => τ_0_0.[SomeProtocol:T]}}
810
911// rdar://problem/19840527
1012
1113class X < T> where T == X { // expected-error{{same-type constraint 'T' == 'X<T>' is recursive}}
12- // expected-error@-1{{same-type requirement makes generic parameter 'T' non-generic}}
13- // expected-error@-2 3{{generic class 'X' has self-referential generic requirements}}
14+ // expected-error@-1 {{cannot build rewrite system for generic signature; concrete nesting limit exceeded}}
15+ // expected-note@-2 {{failed rewrite rule is τ_0_0.[concrete: X<X<X<X<X<X<X<X<X<X<X<X<X<X<X<X<X<X<X<X<X<X<X<X<X<X<X<X<X<X<τ_0_0>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>] => τ_0_0}}
16+ // expected-error@-3{{same-type requirement makes generic parameter 'T' non-generic}}
17+ // expected-error@-4 6{{generic class 'X' has self-referential generic requirements}}
1418 var type : T { return Swift . type ( of: self ) } // expected-error{{cannot convert return expression of type 'X<T>.Type' to return type 'T'}}
1519}
1620
@@ -45,7 +49,7 @@ public protocol P {
4549}
4650
4751public struct S < A: P > where A. T == S < A > {
48- // expected-error@-1 3 {{generic struct 'S' has self-referential generic requirements}}
52+ // expected-error@-1 6 {{generic struct 'S' has self-referential generic requirements}}
4953 func f( a: A . T ) {
5054 g ( a: id ( t: a) ) // `a` has error type which is diagnosed as circular reference
5155 _ = A . T. self
@@ -70,7 +74,7 @@ protocol PI {
7074}
7175
7276struct SI < A: PI > : I where A : I , A. T == SI < A > {
73- // expected-error@-1 3 {{generic struct 'SI' has self-referential generic requirements}}
77+ // expected-error@-1 6 {{generic struct 'SI' has self-referential generic requirements}}
7478 func ggg< T : I > ( t: T . Type ) -> T {
7579 return T ( )
7680 }
@@ -97,9 +101,9 @@ struct S5<A: PI> : I where A : I, A.T == S4<A> { }
97101
98102// Used to hit ArchetypeBuilder assertions
99103struct SU < A: P > where A. T == SU {
100- // expected-error@-1 3 {{generic struct 'SU' has self-referential generic requirements}}
104+ // expected-error@-1 6 {{generic struct 'SU' has self-referential generic requirements}}
101105}
102106
103107struct SIU < A: PI > : I where A : I , A. T == SIU {
104- // expected-error@-1 3 {{generic struct 'SIU' has self-referential generic requirements}}
108+ // expected-error@-1 6 {{generic struct 'SIU' has self-referential generic requirements}}
105109}
0 commit comments