Index: pkg/analyzer/test/src/summary/resynthesize_common.dart |
diff --git a/pkg/analyzer/test/src/summary/resynthesize_common.dart b/pkg/analyzer/test/src/summary/resynthesize_common.dart |
index 3690098b1c5b37b7cc86d8aacfa255dd4e922633..1bdba6ef9812ac509379a41b73ee8eaaeb5704f5 100644 |
--- a/pkg/analyzer/test/src/summary/resynthesize_common.dart |
+++ b/pkg/analyzer/test/src/summary/resynthesize_common.dart |
@@ -3273,6 +3273,52 @@ f() {}'''); |
checkLibrary('f() {} g() {}'); |
} |
+ test_futureOr() { |
+ var library = checkLibrary('import "dart:async"; FutureOr<int> x;'); |
+ var variables = library.definingCompilationUnit.topLevelVariables; |
+ expect(variables, hasLength(1)); |
+ if (createOptions().strongMode) { |
+ expect(variables[0].type.toString(), 'FutureOr<int>'); |
+ } else { |
+ expect(variables[0].type.toString(), 'dynamic'); |
+ } |
+ } |
+ |
+ test_futureOr_const() { |
+ var library = checkLibrary('import "dart:async"; const x = FutureOr;'); |
+ var variables = library.definingCompilationUnit.topLevelVariables; |
+ expect(variables, hasLength(1)); |
+ var x = variables[0] as ConstTopLevelVariableElementImpl; |
+ if (createOptions().strongMode) { |
+ expect(x.type.toString(), 'Type'); |
+ } else { |
+ expect(x.type.toString(), 'dynamic'); |
+ } |
+ expect(x.constantInitializer.toString(), 'FutureOr'); |
+ } |
+ |
+ test_futureOr_inferred() { |
+ var library = checkLibrary(''' |
+import "dart:async"; |
+FutureOr<int> f() => null; |
+var x = f(); |
+var y = x.then((z) => z.asDouble()); |
+'''); |
+ var variables = library.definingCompilationUnit.topLevelVariables; |
+ expect(variables, hasLength(2)); |
+ var x = variables[0]; |
+ expect(x.name, 'x'); |
+ var y = variables[1]; |
+ expect(y.name, 'y'); |
+ if (createOptions().strongMode) { |
+ expect(x.type.toString(), 'FutureOr<int>'); |
+ expect(y.type.toString(), 'dynamic'); |
+ } else { |
+ expect(x.type.toString(), 'dynamic'); |
+ expect(y.type.toString(), 'dynamic'); |
+ } |
+ } |
+ |
test_generic_gClass_gMethodStatic() { |
prepareAnalysisContext(createOptions()); |
checkLibrary(''' |