blob: c7c7f3ee465ec67cf5d89500d1945d6cd30fcc82 [file] [log] [blame]
library test /*isNonNullableByDefault*/;
//
// Problems in library:
//
// pkg/front_end/testcases/inference/future_then_conditional2_6.dart:23:49: Error: A value of type 'Object' can't be returned from an async function with return type 'Future<int>'.
// - 'Object' is from 'dart:core'.
// - 'Future' is from 'dart:async'.
// return /*info:DOWN_CAST_COMPOSITE*/ await x ? 2 : new Future<int>.value(3);
// ^
//
// pkg/front_end/testcases/inference/future_then_conditional2_6.dart:28:13: Error: A value of type 'Object' can't be returned from a function with return type 'FutureOr<int>'.
// - 'Object' is from 'dart:core'.
// x ? 2 : new Future<int>.value(3));
// ^
//
// pkg/front_end/testcases/inference/future_then_conditional2_6.dart:31:43: Error: A value of type 'Object' can't be returned from a function with return type 'FutureOr<int>'.
// - 'Object' is from 'dart:core'.
// return /*info:DOWN_CAST_COMPOSITE*/ x ? 2 : new Future<int>.value(3);
// ^
//
import self as self;
import "dart:core" as core;
import "dart:async" as asy;
import "dart:async";
class MyFuture<T extends core::Object? = dynamic> extends core::Object implements asy::Future<self::MyFuture::T%> {
constructor •() self::MyFuture<self::MyFuture::T%>
: super core::Object::•() {}
constructor value(self::MyFuture::T% x) self::MyFuture<self::MyFuture::T%>
: super core::Object::•() {}
method noSuchMethod(core::Invocation invocation) dynamic
return null;
method then<S extends core::Object? = dynamic>((self::MyFuture::T%) FutureOr<self::MyFuture::then::S%>f, {core::Function? onError = #C1}) → self::MyFuture<self::MyFuture::then::S%>
return throw "";
no-such-method-forwarder method /* from org-dartlang-sdk:///sdk/lib/async/future.dart */ catchError(core::Function onError, {(core::Object) →? core::bool test = #C1}) → asy::Future<self::MyFuture::T%>
return this.{self::MyFuture::noSuchMethod}(new core::_InvocationMirror::_withType(#C2, 0, #C3, core::List::unmodifiable<dynamic>(<dynamic>[onError]), core::Map::unmodifiable<core::Symbol*, dynamic>(<core::Symbol*, dynamic>{#C4: test}))){(core::Invocation) → dynamic} as{TypeError,ForDynamic,ForNonNullableByDefault} asy::Future<self::MyFuture::T%>;
no-such-method-forwarder method /* from org-dartlang-sdk:///sdk/lib/async/future.dart */ whenComplete(() FutureOr<void>action) asy::Future<self::MyFuture::T%>
return this.{self::MyFuture::noSuchMethod}(new core::_InvocationMirror::_withType(#C5, 0, #C3, core::List::unmodifiable<dynamic>(<dynamic>[action]), core::Map::unmodifiable<core::Symbol*, dynamic>(#C6))){(core::Invocation) → dynamic} as{TypeError,ForDynamic,ForNonNullableByDefault} asy::Future<self::MyFuture::T%>;
no-such-method-forwarder method /* from org-dartlang-sdk:///sdk/lib/async/future.dart */ timeout(core::Duration timeLimit, {covariant-by-class () →? FutureOr<self::MyFuture::T%>onTimeout = #C1}) → asy::Future<self::MyFuture::T%>
return this.{self::MyFuture::noSuchMethod}(new core::_InvocationMirror::_withType(#C7, 0, #C3, core::List::unmodifiable<dynamic>(<dynamic>[timeLimit]), core::Map::unmodifiable<core::Symbol*, dynamic>(<core::Symbol*, dynamic>{#C8: onTimeout}))){(core::Invocation) → dynamic} as{TypeError,ForDynamic,ForNonNullableByDefault} asy::Future<self::MyFuture::T%>;
no-such-method-forwarder method /* from org-dartlang-sdk:///sdk/lib/async/future.dart */ asStream() asy::Stream<self::MyFuture::T%>
return this.{self::MyFuture::noSuchMethod}(new core::_InvocationMirror::_withType(#C9, 0, #C3, #C10, core::Map::unmodifiable<core::Symbol*, dynamic>(#C6))){(core::Invocation) → dynamic} as{TypeError,ForDynamic,ForNonNullableByDefault} asy::Stream<self::MyFuture::T%>;
}
static method test(asy::Future<core::bool> f) void {
asy::Future<core::int> t1 = f.{asy::Future::then}<core::int>((core::bool x) asy::Future<core::int> async /* futureValueType= core::int */ => x ?{core::int} 2 : await asy::Future::value<core::int>(3)){((core::bool) FutureOr<core::int>, {onError: core::Function?}) asy::Future<core::int>};
asy::Future<core::int> t2 = f.{asy::Future::then}<core::int>((core::bool x) asy::Future<core::int> async /* futureValueType= core::int */ {
return invalid-expression "pkg/front_end/testcases/inference/future_then_conditional2_6.dart:23:49: Error: A value of type 'Object' can't be returned from an async function with return type 'Future<int>'.
- 'Object' is from 'dart:core'.
- 'Future' is from 'dart:async'.
return /*info:DOWN_CAST_COMPOSITE*/ await x ? 2 : new Future<int>.value(3);
^" in (await x ?{core::Object} 2 : asy::Future::value<core::int>(3)) as{TypeError,ForNonNullableByDefault} core::int;
}){((core::bool) FutureOr<core::int>, {onError: core::Function?}) asy::Future<core::int>};
asy::Future<core::int> t5 = f.{asy::Future::then}<core::int>((core::bool x) FutureOr<core::int> => invalid-expression "pkg/front_end/testcases/inference/future_then_conditional2_6.dart:28:13: Error: A value of type 'Object' can't be returned from a function with return type 'FutureOr<int>'.
- 'Object' is from 'dart:core'.
x ? 2 : new Future<int>.value(3));
^" in (x ?{core::Object} 2 : asy::Future::value<core::int>(3)) as{TypeError,ForNonNullableByDefault} FutureOr<core::int>){((core::bool) FutureOr<core::int>, {onError: core::Function?}) asy::Future<core::int>};
asy::Future<core::int> t6 = f.{asy::Future::then}<core::int>((core::bool x) FutureOr<core::int> {
return invalid-expression "pkg/front_end/testcases/inference/future_then_conditional2_6.dart:31:43: Error: A value of type 'Object' can't be returned from a function with return type 'FutureOr<int>'.
- 'Object' is from 'dart:core'.
return /*info:DOWN_CAST_COMPOSITE*/ x ? 2 : new Future<int>.value(3);
^" in (x ?{core::Object} 2 : asy::Future::value<core::int>(3)) as{TypeError,ForNonNullableByDefault} FutureOr<core::int>;
}){((core::bool) FutureOr<core::int>, {onError: core::Function?}) asy::Future<core::int>};
}
static method main() dynamic {}
constants {
#C1 = null
#C2 = #catchError
#C3 = <core::Type*>[]
#C4 = #test
#C5 = #whenComplete
#C6 = <core::Symbol*, dynamic>{)
#C7 = #timeout
#C8 = #onTimeout
#C9 = #asStream
#C10 = <dynamic>[]
}