File tree Expand file tree Collapse file tree 1 file changed +4
-0
lines changed Expand file tree Collapse file tree 1 file changed +4
-0
lines changed Original file line number Diff line number Diff line change @@ -69,16 +69,19 @@ protocol CollectionOf: Collection {
69
69
extension Array : CollectionOf { }
70
70
extension Set : CollectionOf { }
71
71
72
+ @available ( SwiftStdlib 5 . 1 , * )
72
73
func reverseIt< T> ( _ c: some CollectionOf < T > ) -> some CollectionOf < T > {
73
74
return c. reversed ( )
74
75
}
75
76
77
+ @available ( SwiftStdlib 5 . 1 , * )
76
78
func useReverseIt( _ c: any CollectionOf ) {
77
79
let c = reverseIt ( c)
78
80
let _: Int = c // expected-error{{cannot convert value of type 'CollectionOf' to specified type 'Int'}}
79
81
}
80
82
81
83
/// --- Opening existentials when returning opaque types.
84
+ @available ( SwiftStdlib 5 . 1 , * )
82
85
extension P {
83
86
func getQ( ) -> some Q {
84
87
let a : A ? = nil
@@ -90,6 +93,7 @@ extension P {
90
93
}
91
94
}
92
95
96
+ @available ( SwiftStdlib 5 . 1 , * )
93
97
func testReturningOpaqueTypes( p: any P ) {
94
98
let q = p. getQ ( )
95
99
let _: Int = q // expected-error{{cannot convert value of type 'Q' to specified type 'Int'}}
You can’t perform that action at this time.
0 commit comments