@@ -163,15 +163,15 @@ struct OuterGeneric<D> {
163
163
protocol InnerProtocol { // expected-error{{protocol 'InnerProtocol' cannot be nested in a generic context}}
164
164
associatedtype Rooster
165
165
func flip( _ r: Rooster )
166
- func flop( _ t: D )
166
+ func flop( _ t: D ) // expected-error {{cannot find type 'D' in scope}}
167
167
}
168
168
}
169
169
170
170
class OuterGenericClass < T> {
171
171
protocol InnerProtocol { // expected-error{{protocol 'InnerProtocol' cannot be nested in a generic context}}
172
172
associatedtype Rooster
173
173
func flip( _ r: Rooster )
174
- func flop( _ t: T )
174
+ func flop( _ t: T ) // expected-error {{cannot find type 'T' in scope}}
175
175
}
176
176
}
177
177
@@ -180,7 +180,7 @@ protocol OuterProtocol {
180
180
protocol InnerProtocol { // expected-error{{protocol 'InnerProtocol' cannot be nested in protocol 'OuterProtocol'}}
181
181
associatedtype Rooster
182
182
func flip( _ r: Rooster )
183
- func flop( _ h: Hen )
183
+ func flop( _ h: Hen ) // expected-error {{cannot find type 'Hen' in scope}}
184
184
}
185
185
}
186
186
@@ -195,37 +195,40 @@ struct ConformsToOuterProtocol : OuterProtocol {
195
195
196
196
extension OuterProtocol {
197
197
func f( ) {
198
- protocol Invalid_0 { } // expected-error{{protocol 'Invalid_0' cannot be nested in a generic context }}
198
+ protocol Invalid_0 { } // expected-error{{type 'Invalid_0' cannot be nested in generic function 'f()' }}
199
199
200
200
struct SomeType { // expected-error{{type 'SomeType' cannot be nested in generic function 'f()'}}
201
201
protocol Invalid_1 { } // expected-error{{protocol 'Invalid_1' cannot be nested in a generic context}}
202
202
}
203
203
}
204
204
func g< T> ( _: T ) {
205
- protocol Invalid_2 { } // expected-error{{protocol 'Invalid_2' cannot be nested in a generic context }}
205
+ protocol Invalid_2 { } // expected-error{{type 'Invalid_2' cannot be nested in generic function 'g' }}
206
206
}
207
207
}
208
208
209
209
// 'InnerProtocol' does not inherit the generic parameters of
210
210
// 'OtherGenericClass', so the occurrence of 'OtherGenericClass'
211
211
// in 'InnerProtocol' is not "in context" with implicitly
212
212
// inferred generic arguments <T, U>.
213
- class OtherGenericClass < T, U> {
213
+ class OtherGenericClass < T, U> { // expected-note {{generic type 'OtherGenericClass' declared here}}
214
214
protocol InnerProtocol : OtherGenericClass { }
215
- // expected-error@-1{{protocol 'InnerProtocol' cannot be nested in a generic context}}
215
+ // expected-error@-1 {{protocol 'InnerProtocol' cannot be nested in a generic context}}
216
+ // expected-error@-2 {{reference to generic type 'OtherGenericClass' requires arguments in <...>}}
216
217
}
217
218
218
219
protocol InferredGenericTest {
219
220
associatedtype A
220
221
}
221
222
extension OtherGenericClass {
222
- protocol P : InferredGenericTest where Self. A == T { } // expected-error {{protocol 'P' cannot be nested in a generic context}}
223
+ protocol P : InferredGenericTest where Self. A == T { }
224
+ // expected-error@-1 {{protocol 'P' cannot be nested in a generic context}}
225
+ // expected-error@-2 {{cannot find type 'T' in scope}}
223
226
}
224
227
225
228
// A nested protocol does not satisfy an associated type requirement.
226
229
227
230
protocol HasAssoc {
228
- associatedtype A // expected-note {{protocol requires nested type 'A'; do you want to add it? }}
231
+ associatedtype A // expected-note {{protocol requires nested type 'A'; add nested type 'A' for conformance }}
229
232
}
230
233
struct ConformsToHasAssoc : HasAssoc { // expected-error {{type 'ConformsToHasAssoc' does not conform to protocol 'HasAssoc'}}
231
234
protocol A { }
@@ -257,12 +260,12 @@ func testLookup<T: OuterForUFI.Inner>(_ x: T) {
257
260
// Protocols cannot be nested inside of generic functions.
258
261
259
262
func invalidProtocolInGeneric< T> ( _: T ) {
260
- protocol Test { } // expected-error{{protocol 'Test' cannot be nested in a generic context }}
263
+ protocol Test { } // expected-error{{type 'Test' cannot be nested in generic function 'invalidProtocolInGeneric' }}
261
264
}
262
265
263
266
struct NestedInGenericMethod < T> {
264
267
func someMethod( ) {
265
- protocol AnotherTest { } // expected-error{{protocol 'AnotherTest' cannot be nested in a generic context }}
268
+ protocol AnotherTest { } // expected-error{{type 'AnotherTest' cannot be nested in generic function 'someMethod()' }}
266
269
}
267
270
}
268
271
0 commit comments