// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. // @dart=2.9 /*@testedFeatures=inference*/ library test; import 'dart:async'; class MyFuture implements Future { MyFuture() {} MyFuture.value(T x) {} dynamic noSuchMethod(invocation) => null; MyFuture then(FutureOr f(T x), {Function onError}) => null; } void test() { MyFuture f; Future t1 = f. /*@ typeArgs=int* */ /*@target=MyFuture.then*/ then( /*@ returnType=Future* */ (/*@ type=bool* */ x) async => x ? 2 : await new Future.value(3)); Future t2 = f. /*@ typeArgs=int* */ /*@target=MyFuture.then*/ then( /*@returnType=FutureOr**/ (/*@ type=bool* */ x) async { return /*info:DOWN_CAST_COMPOSITE*/ await x ? 2 : new Future.value(3); }); Future t5 = f. /*@ typeArgs=int* */ /*@target=MyFuture.then*/ then( /*error:INVALID_CAST_FUNCTION_EXPR*/ /*@ returnType=FutureOr* */ (/*@ type=bool* */ x) => x ? 2 : new Future.value(3)); Future t6 = f. /*@ typeArgs=int* */ /*@target=MyFuture.then*/ then( /*@ returnType=FutureOr* */ (/*@ type=bool* */ x) { return /*info:DOWN_CAST_COMPOSITE*/ x ? 2 : new Future.value(3); }); } main() {}