| library test; |
| // |
| // Problems in library: |
| // |
| // pkg/front_end/testcases/inference/local_return_and_yield.dart:19:38: Error: A value of type 'Future<dynamic Function(dynamic)>' can't be assigned to a variable of type 'FutureOr<int Function(int)>'. |
| // - 'Future' is from 'dart:async'. |
| // return /*@ returnType=dynamic */ (/*@ type=dynamic */ x) => x; |
| // ^ |
| // |
| import self as self; |
| import "dart:core" as core; |
| import "dart:async" as asy; |
| |
| import "dart:async"; |
| |
| typedef IntToInt = (core::int*) →* core::int*; |
| static method main() → dynamic { |
| function a() → (core::int*) →* core::int* { |
| return (core::int* x) → core::int* => x; |
| } |
| function b() → asy::Future<(core::int*) →* core::int*>* /* originally async */ { |
| final asy::_Future<(core::int*) →* core::int*>* :async_future = new asy::_Future::•<(core::int*) →* core::int*>(); |
| core::bool* :is_sync = false; |
| FutureOr<(core::int*) →* core::int*>* :return_value; |
| (dynamic) →* dynamic :async_op_then; |
| (core::Object*, core::StackTrace*) →* dynamic :async_op_error; |
| core::int* :await_jump_var = 0; |
| dynamic :await_ctx_var; |
| function :async_op([dynamic :result, dynamic :exception, dynamic :stack_trace]) → dynamic yielding |
| try { |
| #L1: |
| { |
| :return_value = let final Never* #t1 = invalid-expression "pkg/front_end/testcases/inference/local_return_and_yield.dart:19:38: Error: A value of type 'Future<dynamic Function(dynamic)>' can't be assigned to a variable of type 'FutureOr<int Function(int)>'. |
| - 'Future' is from 'dart:async'. |
| return /*@ returnType=dynamic */ (/*@ type=dynamic */ x) => x; |
| ^" in ((dynamic x) → dynamic => x) as{TypeError} FutureOr<(core::int*) →* core::int*>*; |
| break #L1; |
| } |
| asy::_completeOnAsyncReturn(:async_future, :return_value, :is_sync); |
| return; |
| } |
| on dynamic catch(dynamic exception, core::StackTrace* stack_trace) { |
| asy::_completeOnAsyncError(:async_future, exception, stack_trace, :is_sync); |
| } |
| :async_op_then = asy::_asyncThenWrapperHelper(:async_op); |
| :async_op_error = asy::_asyncErrorWrapperHelper(:async_op); |
| :async_op.call(); |
| :is_sync = true; |
| return :async_future; |
| } |
| function c() → core::Iterable<(core::int*) →* core::int*>* /* originally sync* */ { |
| function :sync_op_gen() → (core::_SyncIterator<dynamic>*, dynamic, dynamic) →* core::bool* { |
| core::int* :await_jump_var = 0; |
| dynamic :await_ctx_var; |
| function :sync_op(core::_SyncIterator<dynamic>* :iterator, dynamic :exception, dynamic :stack_trace) → core::bool* yielding { |
| { |
| { |
| :iterator.{core::_SyncIterator::_current} = (core::int* x) → core::int* => x; |
| [yield] true; |
| } |
| } |
| return false; |
| } |
| return :sync_op; |
| } |
| return new core::_SyncIterable::•<(core::int*) →* core::int*>(:sync_op_gen); |
| } |
| function d() → core::Iterable<(core::int*) →* core::int*>* /* originally sync* */ { |
| function :sync_op_gen() → (core::_SyncIterator<dynamic>*, dynamic, dynamic) →* core::bool* { |
| core::int* :await_jump_var = 0; |
| dynamic :await_ctx_var; |
| function :sync_op(core::_SyncIterator<dynamic>* :iterator, dynamic :exception, dynamic :stack_trace) → core::bool* yielding { |
| { |
| { |
| :iterator.{core::_SyncIterator::_yieldEachIterable} = core::_GrowableList::_literal1<(core::int*) →* core::int*>((core::int* x) → core::int* => x); |
| [yield] true; |
| } |
| } |
| return false; |
| } |
| return :sync_op; |
| } |
| return new core::_SyncIterable::•<(core::int*) →* core::int*>(:sync_op_gen); |
| } |
| function e() → asy::Stream<(core::int*) →* core::int*>* /* originally async* */ { |
| asy::_AsyncStarStreamController<(core::int*) →* core::int*>* :controller; |
| dynamic :controller_stream; |
| (dynamic) →* dynamic :async_op_then; |
| (core::Object*, core::StackTrace*) →* dynamic :async_op_error; |
| core::int* :await_jump_var = 0; |
| dynamic :await_ctx_var; |
| dynamic :saved_try_context_var0; |
| dynamic :saved_try_context_var1; |
| function :async_op([dynamic :result, dynamic :exception, dynamic :stack_trace]) → dynamic yielding |
| try |
| try { |
| #L2: |
| { |
| if(:controller.{asy::_AsyncStarStreamController::add}((core::int* x) → core::int* => x)) |
| return null; |
| else |
| [yield] null; |
| } |
| return; |
| } |
| on dynamic catch(dynamic exception, core::StackTrace* stack_trace) { |
| :controller.{asy::_AsyncStarStreamController::addError}(exception, stack_trace); |
| } |
| finally { |
| :controller.{asy::_AsyncStarStreamController::close}(); |
| } |
| :async_op_then = asy::_asyncThenWrapperHelper(:async_op); |
| :async_op_error = asy::_asyncErrorWrapperHelper(:async_op); |
| :controller = new asy::_AsyncStarStreamController::•<(core::int*) →* core::int*>(:async_op); |
| :controller_stream = :controller.{asy::_AsyncStarStreamController::stream}; |
| return :controller_stream; |
| } |
| function f() → asy::Stream<(core::int*) →* core::int*>* /* originally async* */ { |
| asy::_AsyncStarStreamController<(core::int*) →* core::int*>* :controller; |
| dynamic :controller_stream; |
| (dynamic) →* dynamic :async_op_then; |
| (core::Object*, core::StackTrace*) →* dynamic :async_op_error; |
| core::int* :await_jump_var = 0; |
| dynamic :await_ctx_var; |
| dynamic :saved_try_context_var0; |
| dynamic :saved_try_context_var1; |
| function :async_op([dynamic :result, dynamic :exception, dynamic :stack_trace]) → dynamic yielding |
| try |
| try { |
| #L3: |
| { |
| if(:controller.{asy::_AsyncStarStreamController::addStream}(asy::Stream::fromIterable<(core::int*) →* core::int*>(core::_GrowableList::_literal1<(core::int*) →* core::int*>((core::int* x) → core::int* => x)))) |
| return null; |
| else |
| [yield] null; |
| } |
| return; |
| } |
| on dynamic catch(dynamic exception, core::StackTrace* stack_trace) { |
| :controller.{asy::_AsyncStarStreamController::addError}(exception, stack_trace); |
| } |
| finally { |
| :controller.{asy::_AsyncStarStreamController::close}(); |
| } |
| :async_op_then = asy::_asyncThenWrapperHelper(:async_op); |
| :async_op_error = asy::_asyncErrorWrapperHelper(:async_op); |
| :controller = new asy::_AsyncStarStreamController::•<(core::int*) →* core::int*>(:async_op); |
| :controller_stream = :controller.{asy::_AsyncStarStreamController::stream}; |
| return :controller_stream; |
| } |
| } |