Skip to content

Commit 6c03882

Browse files
committed
Fix test availability for opaque result types
1 parent fa6c3c1 commit 6c03882

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

test/Constraints/opened_existentials.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,19 @@ protocol CollectionOf: Collection {
6969
extension Array: CollectionOf { }
7070
extension Set: CollectionOf { }
7171

72+
@available(SwiftStdlib 5.1, *)
7273
func reverseIt<T>(_ c: some CollectionOf<T>) -> some CollectionOf<T> {
7374
return c.reversed()
7475
}
7576

77+
@available(SwiftStdlib 5.1, *)
7678
func useReverseIt(_ c: any CollectionOf) {
7779
let c = reverseIt(c)
7880
let _: Int = c // expected-error{{cannot convert value of type 'CollectionOf' to specified type 'Int'}}
7981
}
8082

8183
/// --- Opening existentials when returning opaque types.
84+
@available(SwiftStdlib 5.1, *)
8285
extension P {
8386
func getQ() -> some Q {
8487
let a: A? = nil
@@ -90,6 +93,7 @@ extension P {
9093
}
9194
}
9295

96+
@available(SwiftStdlib 5.1, *)
9397
func testReturningOpaqueTypes(p: any P) {
9498
let q = p.getQ()
9599
let _: Int = q // expected-error{{cannot convert value of type 'Q' to specified type 'Int'}}

0 commit comments

Comments
 (0)