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 3c4d55b8bddf85eb8257f03cc0472ab6951b4425..1287fa3992e3900ba31e4e4cfd2aa0d447c178d0 100644 |
| --- a/pkg/analyzer/test/src/task/strong/inferred_type_test.dart |
| +++ b/pkg/analyzer/test/src/task/strong/inferred_type_test.dart |
| @@ -1694,7 +1694,7 @@ main() { |
| Iterable<Future<int>> list = <int>[1, 2, 3].map(make); |
| Future<List<int>> results = Future.wait(list); |
| Future<String> results2 = results.then((List<int> list) |
| - => list.fold('', (String x, int y) => x + y.toString())); |
| + => list.fold('', /*info:INFERRED_TYPE_CLOSURE*/(x, y) => x + y.toString())); |
|
Leaf
2016/02/19 23:19:04
Nice!
Jennifer Messerly
2016/02/20 01:14:12
yeah, I was happy to see that some basic `fold` ca
|
| } |
| '''); |
| }); |
| @@ -1837,7 +1837,7 @@ main() { |
| test('correctly recognize generic upper bound', () { |
| // Regression test for https://github.com/dart-lang/sdk/issues/25740. |
| - checkFile(''' |
| + checkFile(r''' |
| class Foo<T extends Pattern> { |
| void method/*<U extends T>*/(dynamic/*=U*/ u) {} |
| } |
| @@ -1852,11 +1852,52 @@ main() { |
| } |
| '''); |
| }); |
| + |
| + test('basic downwards inference', () { |
| + checkFile(r''' |
| +/*=T*/ f/*<S, T>*/(/*=S*/ s) => null; |
| +main() { |
| + String x = f(42); |
|
Leaf
2016/02/19 23:19:03
What tells us that this test succeeds? I guess ma
Jennifer Messerly
2016/02/20 01:14:12
yup, exactly. If T was `dynamic` we'd get a downca
|
| + String y = (f)(42); |
| +} |
| + '''); |
| + }); |
| + |
| + test('downwards inference affects arguments', () { |
| + checkFile(r''' |
| +/*=T*/ f/*<T>*/(List/*<T>*/ s) => null; |
| +main() { |
| + String x = f(/*info:INFERRED_TYPE_LITERAL*/['hi']); |
| + String y = f(/*info:INFERRED_TYPE_LITERAL*/[/*severe:STATIC_TYPE_ERROR*/42]); |
| +} |
| + '''); |
| + }); |
| + |
| + test('downwards inference fold', () { |
| + // Regression from https://github.com/dart-lang/sdk/issues/25491 |
| + // The first example works now, but the latter requires a full solution to |
| + // https://github.com/dart-lang/sdk/issues/25490 |
| + checkFile(r''' |
| +void main() { |
| + List<int> o; |
| + int y = o.fold(0, /*info:INFERRED_TYPE_CLOSURE*/(x, y) => x + y); |
| + var z = o.fold(0, /*info:INFERRED_TYPE_CLOSURE*/(x, y) => /*info:DYNAMIC_INVOKE*/x + y); |
| + y = /*info:DYNAMIC_CAST*/z; |
| +} |
| +void functionExpressionInvocation() { |
| + List<int> o; |
| + int y = (o.fold)(0, /*info:INFERRED_TYPE_CLOSURE*/(x, y) => x + y); |
| + var z = (o.fold)(0, /*info:INFERRED_TYPE_CLOSURE*/(x, y) => /*info:DYNAMIC_INVOKE*/x + y); |
| + y = /*info:DYNAMIC_CAST*/z; |
| +} |
| + '''); |
| + }); |
| + |
| }); |
| // Regression test for https://github.com/dart-lang/dev_compiler/issues/47 |
| test('null literal should not infer as bottom', () { |
| - checkFile(''' |
| + checkFile(r''' |
| var h = null; |
| void foo(int f(Object _)) {} |