Skip to content

Commit 9c9af90

Browse files
[test] Add opaque result type cases
1 parent 7300fb5 commit 9c9af90

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

test/expr/closure/closures.swift

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -751,6 +751,22 @@ public class TestImplicitCaptureOfExplicitCaptureOfSelfInEscapingClosure {
751751
return s.isEmpty
752752
}.filter { $0 }
753753

754+
func producer<T>(_ f: (String) -> T) -> T {}
755+
func f59716() -> some BinaryInteger { // expected-note{{required by opaque return type of global function 'f59716()'}}
756+
// expected-note@+1{{only concrete types such as structs, enums and classes can conform to protocols}}
757+
return producer { s in // expected-error{{type '()' cannot conform to 'BinaryInteger'}}
758+
if s == "1" { return }
759+
return s.count // expected-error{{cannot convert value of type 'Int' to closure result type '()'}}
760+
}
761+
}
762+
763+
func f59716_1() -> some BinaryInteger {
764+
return producer { s in
765+
if s == "1" { return 1 }
766+
return s.count
767+
}
768+
}
769+
754770
// https://github.com/apple/swift/issues/60781
755771
func f60781<T>(_ x: T) -> T { x }
756772
func f60781<T>(_ x: T, _ y: T) -> T { x }

0 commit comments

Comments
 (0)