@@ -163,15 +163,15 @@ struct OuterGeneric<D> {
163163 protocol InnerProtocol { // expected-error{{protocol 'InnerProtocol' cannot be nested in a generic context}}
164164 associatedtype Rooster
165165 func flip( _ r: Rooster )
166- func flop( _ t: D )
166+ func flop( _ t: D ) // expected-error {{cannot find type 'D' in scope}}
167167 }
168168}
169169
170170class OuterGenericClass < T> {
171171 protocol InnerProtocol { // expected-error{{protocol 'InnerProtocol' cannot be nested in a generic context}}
172172 associatedtype Rooster
173173 func flip( _ r: Rooster )
174- func flop( _ t: T )
174+ func flop( _ t: T ) // expected-error {{cannot find type 'T' in scope}}
175175 }
176176}
177177
@@ -180,7 +180,7 @@ protocol OuterProtocol {
180180 protocol InnerProtocol { // expected-error{{protocol 'InnerProtocol' cannot be nested in protocol 'OuterProtocol'}}
181181 associatedtype Rooster
182182 func flip( _ r: Rooster )
183- func flop( _ h: Hen )
183+ func flop( _ h: Hen ) // expected-error {{cannot find type 'Hen' in scope}}
184184 }
185185}
186186
@@ -195,37 +195,40 @@ struct ConformsToOuterProtocol : OuterProtocol {
195195
196196extension OuterProtocol {
197197 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()' }}
199199
200200 struct SomeType { // expected-error{{type 'SomeType' cannot be nested in generic function 'f()'}}
201201 protocol Invalid_1 { } // expected-error{{protocol 'Invalid_1' cannot be nested in a generic context}}
202202 }
203203 }
204204 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' }}
206206 }
207207}
208208
209209// 'InnerProtocol' does not inherit the generic parameters of
210210// 'OtherGenericClass', so the occurrence of 'OtherGenericClass'
211211// in 'InnerProtocol' is not "in context" with implicitly
212212// inferred generic arguments <T, U>.
213- class OtherGenericClass < T, U> {
213+ class OtherGenericClass < T, U> { // expected-note {{generic type 'OtherGenericClass' declared here}}
214214 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 <...>}}
216217}
217218
218219protocol InferredGenericTest {
219220 associatedtype A
220221}
221222extension 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}}
223226}
224227
225228// A nested protocol does not satisfy an associated type requirement.
226229
227230protocol 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 }}
229232}
230233struct ConformsToHasAssoc : HasAssoc { // expected-error {{type 'ConformsToHasAssoc' does not conform to protocol 'HasAssoc'}}
231234 protocol A { }
@@ -257,12 +260,12 @@ func testLookup<T: OuterForUFI.Inner>(_ x: T) {
257260// Protocols cannot be nested inside of generic functions.
258261
259262func 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' }}
261264}
262265
263266struct NestedInGenericMethod < T> {
264267 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()' }}
266269 }
267270}
268271
0 commit comments