@@ -35,13 +35,16 @@ def run(x: object) -> object: ...
3535[typing fixtures/typing-full.pyi]
3636
3737[case testRunAsyncAwaitInVariousPositions]
38+ from typing import cast, Any
39+
3840import asyncio
3941
4042async def one() -> int:
43+ await asyncio.sleep(0.0)
4144 return int() + 1
4245
4346async def true() -> bool:
44- return bool(int() + 1 )
47+ return bool(int() + await one() )
4548
4649async def branch_await() -> int:
4750 if await true():
@@ -124,6 +127,33 @@ async def construct(s: str) -> str:
124127def test_construct() -> None:
125128 assert asyncio.run(construct("foo")) == "foo!"
126129
130+ async def repr_as_object(s: str) -> object:
131+ return repr(s)
132+
133+ async def do_cast(s: str) -> str:
134+ return cast(str, await repr_as_object(s))
135+
136+ def test_cast() -> None:
137+ assert asyncio.run(do_cast("foo")) == "'foo'"
138+
139+ async def box() -> list[int]:
140+ return [await one(), await one()]
141+
142+ def test_box() -> None:
143+ assert asyncio.run(box()) == [1, 1]
144+
145+ async def int_as_any(n: int) -> Any:
146+ return n * 2
147+
148+ async def inc(n: int) -> int:
149+ return n + await one()
150+
151+ async def unbox(n: int) -> int:
152+ return await inc(await int_as_any(n))
153+
154+ def test_unbox() -> None:
155+ assert asyncio.run(unbox(4)) == 9
156+
127157[file asyncio/__init__.pyi]
128158async def sleep(t: float) -> None: ...
129159# eh, we could use the real type but it doesn't seem important
0 commit comments