| library test; |
| // |
| // Problems in library: |
| // |
| // pkg/front_end/testcases/inference/local_return_and_yield.dart:19:36: Error: A value of type 'dynamic Function(dynamic)' can't be assigned to a variable of type 'FutureOr<int Function(int)>'. |
| // - 'FutureOr' is from 'dart:async'. |
| // Try changing the type of the left hand side, or casting the right hand side to 'FutureOr<int Function(int)>'. |
| // 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::_AsyncAwaitCompleter<(core::int) → core::int> :async_completer = new asy::_AsyncAwaitCompleter::•<(core::int) → core::int>(); |
| asy::FutureOr<(core::int) → core::int> :return_value; |
| dynamic :async_stack_trace; |
| dynamic :async_op_then; |
| dynamic :async_op_error; |
| dynamic :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<BottomType> #t1 = invalid-expression "pkg/front_end/testcases/inference/local_return_and_yield.dart:19:36: Error: A value of type 'dynamic Function(dynamic)' can't be assigned to a variable of type 'FutureOr<int Function(int)>'. |
| - 'FutureOr' is from 'dart:async'. |
| Try changing the type of the left hand side, or casting the right hand side to 'FutureOr<int Function(int)>'. |
| return /*@returnType=dynamic*/ (/*@type=dynamic*/ x) => x; |
| ^" in ((dynamic x) → dynamic => x) as{TypeError} asy::FutureOr<(core::int) → core::int>; |
| break #L1; |
| } |
| asy::_completeOnAsyncReturn(:async_completer, :return_value); |
| return; |
| } |
| on dynamic catch(dynamic :exception, dynamic :stack_trace) { |
| :async_completer.{asy::Completer::completeError}(:exception, :stack_trace); |
| } |
| :async_stack_trace = asy::_asyncStackTraceHelper(:async_op); |
| :async_op_then = asy::_asyncThenWrapperHelper(:async_op); |
| :async_op_error = asy::_asyncErrorWrapperHelper(:async_op); |
| :async_completer.start(:async_op); |
| return :async_completer.{asy::Completer::future}; |
| } |
| function c() → core::Iterable<(core::int) → core::int> /* originally sync* */ { |
| dynamic :await_jump_var = 0; |
| dynamic :await_ctx_var; |
| function :sync_op(core::_SyncIterator<(core::int) → core::int> :iterator) → core::bool yielding { |
| { |
| { |
| :iterator.{core::_SyncIterator::_current} = (core::int x) → core::int => x; |
| [yield] true; |
| } |
| } |
| return false; |
| } |
| return new core::_SyncIterable::•<(core::int) → core::int>(:sync_op); |
| } |
| function d() → core::Iterable<(core::int) → core::int> /* originally sync* */ { |
| dynamic :await_jump_var = 0; |
| dynamic :await_ctx_var; |
| function :sync_op(core::_SyncIterator<(core::int) → core::int> :iterator) → core::bool yielding { |
| { |
| { |
| :iterator.{core::_SyncIterator::_yieldEachIterable} = <(core::int) → core::int>[(core::int x) → core::int => x]; |
| [yield] true; |
| } |
| } |
| return false; |
| } |
| return new core::_SyncIterable::•<(core::int) → core::int>(:sync_op); |
| } |
| function e() → asy::Stream<(core::int) → core::int> /* originally async* */ { |
| asy::_AsyncStarStreamController<(core::int) → core::int> :controller; |
| dynamic :controller_stream; |
| dynamic :async_stack_trace; |
| dynamic :async_op_then; |
| dynamic :async_op_error; |
| dynamic :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, dynamic :stack_trace) { |
| :controller.{asy::_AsyncStarStreamController::addError}(:exception, :stack_trace); |
| } |
| finally { |
| :controller.{asy::_AsyncStarStreamController::close}(); |
| } |
| :async_stack_trace = asy::_asyncStackTraceHelper(:async_op); |
| :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 :async_stack_trace; |
| dynamic :async_op_then; |
| dynamic :async_op_error; |
| dynamic :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::int) → core::int>[(core::int x) → core::int => x]))) |
| return null; |
| else |
| [yield] null; |
| } |
| return; |
| } |
| on dynamic catch(dynamic :exception, dynamic :stack_trace) { |
| :controller.{asy::_AsyncStarStreamController::addError}(:exception, :stack_trace); |
| } |
| finally { |
| :controller.{asy::_AsyncStarStreamController::close}(); |
| } |
| :async_stack_trace = asy::_asyncStackTraceHelper(:async_op); |
| :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; |
| } |
| } |