1
- // RUN: %target-typecheck-verify-swift
1
+ // RUN: %target-typecheck-verify-swift -requirement-machine-inferred-signatures=verify
2
2
3
3
protocol SomeProtocol {
4
4
associatedtype T
5
5
}
6
6
7
7
extension 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]}}
8
10
9
11
// rdar://problem/19840527
10
12
11
13
class 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}}
14
18
var type : T { return Swift . type ( of: self ) } // expected-error{{cannot convert return expression of type 'X<T>.Type' to return type 'T'}}
15
19
}
16
20
@@ -45,7 +49,7 @@ public protocol P {
45
49
}
46
50
47
51
public 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}}
49
53
func f( a: A . T ) {
50
54
g ( a: id ( t: a) ) // `a` has error type which is diagnosed as circular reference
51
55
_ = A . T. self
@@ -70,7 +74,7 @@ protocol PI {
70
74
}
71
75
72
76
struct 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}}
74
78
func ggg< T : I > ( t: T . Type ) -> T {
75
79
return T ( )
76
80
}
@@ -97,9 +101,9 @@ struct S5<A: PI> : I where A : I, A.T == S4<A> { }
97
101
98
102
// Used to hit ArchetypeBuilder assertions
99
103
struct 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}}
101
105
}
102
106
103
107
struct 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}}
105
109
}
0 commit comments