Skip to content

Commit 8805213

Browse files
committed
Add typecheck tests for @yield_once / @yields
1 parent 89496aa commit 8805213

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

test/Parse/coroutines.swift

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// RUN: %target-typecheck-verify-swift
2+
3+
@yield_once func coro(_ x : inout Float) -> inout @yields Float {
4+
var _x = Float(0.0)
5+
yield &_x
6+
x = Float(_x)
7+
}
8+
9+
func retCoro() -> @yield_once (_ x : inout Float) -> inout @yields Float {
10+
return coro
11+
}
12+
13+
@yield_once func coroWithResult(_ x : Float) -> (yield: inout @yields Float, result: Float) {
14+
var _x = Float(0.0)
15+
yield &_x
16+
return _x
17+
}
18+
19+
func retCoroWithResult() -> @yield_once (_ x : Float) -> (inout @yields Float, Float) {
20+
return coroWithResult
21+
}
22+
23+
@yield_once func coroGen<T>(_ x : inout T) -> inout @yields T {
24+
var _x = x
25+
yield &_x
26+
x = _x
27+
}
28+
29+
func retGenCoro<T>() -> @yield_once (_ x : inout T) -> inout @yields T {
30+
return coroGen
31+
}
32+
33+
@yield_once func coroGenWithResult<T>(_ x : T) -> (yield: inout @yields T, result: T) {
34+
var _x = x
35+
yield &_x
36+
return _x
37+
}
38+
39+
func retCoroGenWithResult<T>() -> @yield_once (_ x : T) -> (inout @yields T, T) {
40+
return coroGenWithResult
41+
}

0 commit comments

Comments
 (0)