|
| 1 | +library; |
| 2 | +import self as self; |
| 3 | +import "dart:core" as core; |
| 4 | +import "dart:async" as asy; |
| 5 | + |
| 6 | +import "dart:async"; |
| 7 | + |
| 8 | +static method f() → FutureOr<core::Iterable<core::int>> sync* { |
| 9 | + yield("Hello!" as dynamic) as{TypeError,ForDynamic} core::int; |
| 10 | +} |
| 11 | +static method g() → FutureOr<asy::Stream<core::int>> async* { |
| 12 | + yield*("Hello!" as dynamic) as{TypeError,ForDynamic} asy::Stream<core::int>; |
| 13 | +} |
| 14 | +static method main() → dynamic async /* futureValueType= dynamic */ { |
| 15 | + FutureOr<core::Iterable<core::int>>iterable = self::f(); |
| 16 | + if(iterable is asy::Future<core::Object?>) |
| 17 | + return; |
| 18 | + self::expectThrows(() → Null { |
| 19 | + core::int i = iterable{core::Iterable<core::int>}.{core::Iterable::first}{core::int}; |
| 20 | + }); |
| 21 | + FutureOr<asy::Stream<core::int>>stream = self::g(); |
| 22 | + if(stream is asy::Future<core::Object?>) |
| 23 | + return; |
| 24 | + await self::expectAsyncThrows(() → asy::Future<Null> async /* futureValueType= Null */ { |
| 25 | + core::int i = await stream{asy::Stream<core::int>}.{asy::Stream::first}{asy::Future<core::int>}; |
| 26 | + }) /* runtimeCheckType= asy::Future<dynamic> */ ; |
| 27 | +} |
| 28 | +static method expectThrows(dynamic f) → dynamic { |
| 29 | + core::bool hasThrown = true; |
| 30 | + try { |
| 31 | + f{dynamic}.call(); |
| 32 | + hasThrown = false; |
| 33 | + } |
| 34 | + on core::Object catch(final core::Object e) { |
| 35 | + } |
| 36 | + if(!hasThrown) { |
| 37 | + throw "Expected the function to throw."; |
| 38 | + } |
| 39 | +} |
| 40 | +static method expectAsyncThrows(dynamic f) → dynamic async /* futureValueType= dynamic */ { |
| 41 | + core::bool hasThrown = true; |
| 42 | + try { |
| 43 | + await f{dynamic}.call() /* runtimeCheckType= asy::Future<dynamic> */ ; |
| 44 | + hasThrown = false; |
| 45 | + } |
| 46 | + on core::Object catch(final core::Object e) { |
| 47 | + } |
| 48 | + if(!hasThrown) { |
| 49 | + throw "Expected the function to throw."; |
| 50 | + } |
| 51 | +} |
| 52 | + |
| 53 | + |
| 54 | +Extra constant evaluation status: |
| 55 | +Evaluated: AsExpression @ org-dartlang-testcase:///issue53052.dart:8:18 -> StringConstant("Hello!") |
| 56 | +Evaluated: AsExpression @ org-dartlang-testcase:///issue53052.dart:12:19 -> StringConstant("Hello!") |
| 57 | +Extra constant evaluation: evaluated: 33, effectively constant: 2 |
0 commit comments