Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(150)

Unified Diff: pkg/analyzer/test/src/task/strong/inferred_type_test.dart

Issue 2665813002: Fix summary type inference for async closures. (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer/lib/src/summary/link.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 97054d588f17fd25c0cb79d9f635704cc90fffd7..541e75f7ffebee02321c0689812d6c4efa11c630 100644
--- a/pkg/analyzer/test/src/task/strong/inferred_type_test.dart
+++ b/pkg/analyzer/test/src/task/strong/inferred_type_test.dart
@@ -61,6 +61,24 @@ var g = () async => futureInt;
expect(f.type.toString(), '() → Future<int>');
}
+ void test_asyncClosureReturnType_futureOr() {
+ var mainUnit = checkFile('''
+import 'dart:async';
+FutureOr<int> futureOrInt = null;
+var f = () => futureOrInt;
+var g = () async => futureOrInt;
+''');
+ var futureOrInt = mainUnit.topLevelVariables[0];
+ expect(futureOrInt.name, 'futureOrInt');
+ expect(futureOrInt.type.toString(), 'FutureOr<int>');
+ var f = mainUnit.topLevelVariables[1];
+ expect(f.name, 'f');
+ expect(f.type.toString(), '() → FutureOr<int>');
+ var g = mainUnit.topLevelVariables[2];
+ expect(g.name, 'g');
+ expect(g.type.toString(), '() → Future<int>');
+ }
+
void test_blockBodiedLambdas_async_allReturnsAreFutures() {
if (!mayCheckTypesOfLocals) {
return;
@@ -1665,6 +1683,19 @@ int get y => null;
expect(x.type.toString(), 'int');
}
+ void test_futureOr_subtyping() {
+ checkFile(r'''
+import 'dart:async';
+void add(int x) {}
+add2(int y) {}
+main() {
+ Future<int> f;
+ var a = f.then(add);
+ var b = f.then(add2);
+}
+ ''');
+ }
+
void test_futureThen() {
String build({String declared, String downwards, String upwards}) => '''
import 'dart:async';
@@ -1855,19 +1886,6 @@ main() {
''');
}
- void test_futureOr_subtyping() {
- checkFile(r'''
-import 'dart:async';
-void add(int x) {}
-add2(int y) {}
-main() {
- Future<int> f;
- var a = f.then(add);
- var b = f.then(add2);
-}
- ''');
- }
-
void test_futureUnion_asyncConditional() {
String build({String declared, String downwards, String upwards}) => '''
import 'dart:async';
« no previous file with comments | « pkg/analyzer/lib/src/summary/link.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698