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

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

Issue 2520043002: add test, fixes #27808: void return type can subtype dynamic (Closed)
Patch Set: Merge remote-tracking branch 'origin/master' into 27808_void_dyn Created 4 years, 1 month 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 | « no previous file | 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 f38f36244bb1f464cae5f70c9a8482afa6c35524..ae546d5bd34082ff52a9ca1b9438553695659c71 100644
--- a/pkg/analyzer/test/src/task/strong/inferred_type_test.dart
+++ b/pkg/analyzer/test/src/task/strong/inferred_type_test.dart
@@ -4608,6 +4608,37 @@ var v = new C().f(/*info:INFERRED_TYPE_CLOSURE*/() { return 1; });
expect(v.name, 'v');
expect(v.type.toString(), 'double');
}
+
+ void test_voidReturnTypeSubtypesDynamic() {
+ var unit = checkFile(r'''
+/*=T*/ run/*<T>*/(/*=T*/ f()) {
+ print("running");
+ var t = f();
+ print("done running");
+ return t;
+}
+
+
+void printRunning() { print("running"); }
+var x = run/*<dynamic>*/(printRunning);
+var y = run(printRunning);
+
+main() {
+ void printRunning() { print("running"); }
+ var x = run/*<dynamic>*/(printRunning);
+ var y = run(printRunning);
+ x = 123;
+ x = 'hi';
+ y = 123;
+ y = 'hi';
+}
+ ''');
+
+ var x = unit.topLevelVariables[0];
+ var y = unit.topLevelVariables[1];
+ expect(x.type.toString(), 'dynamic');
+ expect(y.type.toString(), 'dynamic');
+ }
}
@reflectiveTest
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698