blob: ac9692a5b5419a60036bf62ad106575a264ffd00 [file] [edit]
library;
import self as self;
import "dart:async" as asy;
import "dart:core" as core;
import "dart:async";
static field (asy::Future<core::int>) → asy::Future<Null> asyncInFieldInitializer = (asy::Future<core::int> x) → asy::Future<Null> async /* emittedValueType= Null */ /* scope=[
#ctx1: not-captured [x],
] */ {
await x;
};
static method foo() → asy::Future<core::int> async /* emittedValueType= core::int */
return 42;
static method simpleAsyncAwait(asy::Future<core::int> a, asy::Future<core::int> b) → asy::Future<core::int> async /* emittedValueType= core::int */ /* scope=[
#ctx2: not-captured [a,b],
] */ {
return (await a).{core::num::+}(await b){(core::num) → core::int};
}
static method loops(core::List<core::int> list) → asy::Future<core::int> async /* emittedValueType= core::int */ /* scope=[
#ctx3: not-captured [list],
] */ /* scope=[
#ctx4: not-captured [sum],
] */ {
core::int sum = 0;
for /* scope=[
#ctx5: not-captured [i],
] */ (core::int i = 0; i.{core::num::<}(10){(core::num) → core::bool}; i = i.{core::num::+}(1){(core::num) → core::int}) {
for /* scope=[
#ctx6: not-captured [j],
] */ (core::int j in list) {
sum = sum.{core::num::+}(i.{core::num::+}(j){(core::num) → core::int}.{core::num::+}(await self::foo()){(core::num) → core::int}){(core::num) → core::int};
}
}
for /* scope=[
#ctx7: not-captured [k],
] */ (core::int k = 0; k.{core::num::<}(10){(core::num) → core::bool}; k = k.{core::num::+}(1){(core::num) → core::int}) {
sum = sum.{core::num::+}(k){(core::num) → core::int};
}
return sum;
}
static method tryCatchRethrow(asy::Future<core::int> a, asy::Future<core::int> b, asy::Future<core::int> c) → asy::Future<core::int> async /* emittedValueType= core::int */ /* scope=[
#ctx8: not-captured [a,b,c],
] */ /* scope=[
#ctx9: not-captured [x],
] */ {
core::int x = 1;
try
try {
x = x.{core::num::+}(await a){(core::num) → core::int};
}
on core::Object catch(final core::Object e)/* scope=[
#ctx10: not-captured [e],
] */ {
if(e is core::Error) {
return 42;
}
x = x.{core::num::+}(await b){(core::num) → core::int};
rethrow;
}
finally {
core::print("fin");
x = x.{core::num::+}(await c){(core::num) → core::int};
return x;
}
}
static method closure(asy::Future<core::int> a) → dynamic/* scope=[
#ctx11: direct-captured [a],
] */ /* scope=[
#ctx12: direct-captured [x],
#ctx13: not-captured [nested],
] */ {
core::int x = 3;
function nested() /* #ctx11 #ctx12 */ → asy::Future<core::int> async /* emittedValueType= core::int */ /* scope=[
#ctx14: not-captured [y],
] */ {
core::int y = 4;
try {
x = 5;
y = await a;
return x.{core::num::+}(y){(core::num) → core::int};
}
finally {
core::print("fin");
}
}
return nested;
}
static method testAssert(asy::Future<core::int> a) → asy::Future<core::int> async /* emittedValueType= core::int */ /* scope=[
#ctx15: not-captured [a],
] */ {
assert(await a =={core::num::==}{(core::Object) → core::bool} 42);
return 7;
}
static method main() → dynamic {}