You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: test/Constraints/opened_existentials.swift
+16-3Lines changed: 16 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -311,15 +311,28 @@ class C1 {}
311
311
classC2<T>:C1{}
312
312
313
313
// Protocols With Associated Types
314
-
protocolT{
314
+
protocolP1{
315
315
associatedtypeA
316
316
associatedtypeB:C2<A>
317
317
318
318
func returnAssocTypeB()->B
319
319
}
320
320
321
-
func testAssocReturn(p:anyT){
322
-
let _ = p.returnAssocTypeB() // expected-error {{inferred result type 'C2<(any T).A>' requires explicit coercion due to loss of generic requirements}} {{29-29=as C2<(any T).A>}}
321
+
func testAssocReturn(p:anyP1){ // should return C1
322
+
let _ = p.returnAssocTypeB() // expected-error {{inferred result type 'C2<(any T).A>' requires explicit coercion due to loss of generic requirements}} {{29-29=as C2<(any P1).A>}}
323
+
}
324
+
325
+
326
+
// Protocols With Associated Types
327
+
protocolP2<A>{
328
+
associatedtypeA
329
+
associatedtypeB:C2<A>
330
+
331
+
func returnAssocTypeB()->B
332
+
}
333
+
334
+
func testAssocReturn(p:anyP2<Int>){ // should return C2<A>
335
+
let _ = p.returnAssocTypeB() // expected-error {{inferred result type 'C2<(any P2).A>' requires explicit coercion due to loss of generic requirements}} {{29-29=as C2<(any P2).A>}}
0 commit comments