Chromium Code Reviews| Index: pkg/analyzer/test/src/task/strong/inferred_type_test.dart |
| diff --git a/pkg/analyzer/test/src/task/strong/inferred_type_test.dart b/pkg/analyzer/test/src/task/strong/inferred_type_test.dart |
| index 741659a2822bad3484d6af9030708eb1b282277d..cb2d7b1ce88f4ef86174c9f2c5eff4ed9211479b 100644 |
| --- a/pkg/analyzer/test/src/task/strong/inferred_type_test.dart |
| +++ b/pkg/analyzer/test/src/task/strong/inferred_type_test.dart |
| @@ -890,7 +890,7 @@ void main() { |
| import 'dart:async'; |
| Future test() async { |
| dynamic d; |
| - List<int> l0 = /*warning:DOWN_CAST_COMPOSITE should be pass*/await /*pass should be info:INFERRED_TYPE_LITERAL*/[d]; |
| + List<int> l0 = await /*info:INFERRED_TYPE_LITERAL*/[/*info:DYNAMIC_CAST*/d]; |
| List<int> l1 = await /*info:INFERRED_TYPE_ALLOCATION*/new Future.value(/*info:INFERRED_TYPE_LITERAL*/[/*info:DYNAMIC_CAST*/d]); |
| } |
| '''); |
| @@ -1513,7 +1513,53 @@ int get y => null; |
| checkFile(''' |
| import 'dart:async'; |
| Future f; |
| -Future<int> t1 = f.then((_) => new Future<int>.value(42)); |
| +Future<int> t1 = f.then((_) async => await new Future<int>.value(3)); |
| +Future<int> t2 = f.then(/*info:INFERRED_TYPE_CLOSURE*/(_) async {return await new Future<int>.value(3);}); |
| +Future<int> t3 = f.then((_) async => 3); |
| +Future<int> t4 = f.then(/*info:INFERRED_TYPE_CLOSURE*/(_) async {return 3;}); |
| +Future<int> t5 = f.then((_) => new Future<int>.value(3)); |
| +Future<int> t6 = f.then((_) {return new Future<int>.value(3);}); |
| +Future<int> t7 = f.then((_) async => new Future<int>.value(3)); |
| +Future<int> t8 = f.then(/*info:INFERRED_TYPE_CLOSURE*/(_) async {return new Future<int>.value(3);}); |
| +'''); |
|
Leaf
2016/08/05 22:32:35
sweeeet.
|
| + } |
| + |
| + void test_futureThen_conditional() { |
| + checkFile(''' |
| +import 'dart:async'; |
| +Future<bool> f; |
| +Future<int> t1 = f.then((x) async => x ? 2 : await new Future<int>.value(3)); |
| +Future<int> t2 = f.then(/*info:INFERRED_TYPE_CLOSURE*/(x) async {return await x ? 2 : new Future<int>.value(3);}); |
| +Future<int> t5 = f.then((x) => x ? 2 : new Future<int>.value(3)); |
| +Future<int> t6 = f.then((x) {return x ? 2 : new Future<int>.value(3);}); |
| +'''); |
| + } |
| + |
| + void test_futureUnion_asyncConditional() { |
| + checkFile(''' |
| +import 'dart:async'; |
| + |
| +Future<int> g1(bool x) async { return x ? 42 : /*info:INFERRED_TYPE_ALLOCATION*/new Future.value(42); } |
| +Future<int> g2(bool x) async => x ? 42 : /*info:INFERRED_TYPE_ALLOCATION*/new Future.value(42); |
| + |
| +Future<int> g3(bool x) async { |
| + var y = x ? 42 : /*info:INFERRED_TYPE_ALLOCATION*/new Future.value(42); |
| + return y; |
| +} |
| + '''); |
| + } |
| + |
| + void test_futureUnion_downwards() { |
| + checkFile(''' |
| +import 'dart:async'; |
| +Future f; |
| +// Instantiates Future<int> |
| +Future<int> t1 = f.then((_) => /*info:INFERRED_TYPE_ALLOCATION*/new Future.value(/*error:ARGUMENT_TYPE_NOT_ASSIGNABLE*/'hi')); |
| + |
| +// Instantiates List<int> |
| +Future<List<int>> t2 = f.then((_) => /*info:INFERRED_TYPE_LITERAL*/[3]); |
| +Future<List<int>> g2() async { return /*info:INFERRED_TYPE_LITERAL*/[3]; } |
| +Future<List<int>> g3() async { return /*info:INFERRED_TYPE_ALLOCATION*/new Future.value(/*info:INFERRED_TYPE_LITERAL*/[3]); } |
| '''); |
| } |