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

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

Issue 2014383003: Make AST-based type inference handle <bottom> consistently. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 7 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 7eec4c6a0af9fdef355ee9e5e5274aaf802144fc..76459a759897f78015b60c20d3ac68676fc7d844 100644
--- a/pkg/analyzer/test/src/task/strong/inferred_type_test.dart
+++ b/pkg/analyzer/test/src/task/strong/inferred_type_test.dart
@@ -449,6 +449,29 @@ var f = /*info:INFERRED_TYPE_CLOSURE*/() sync* {
expect(f.type.toString(), '() → Iterable<num>');
}
+ void test_bottom() {
+ // When a type is inferred from the expression `null`, the inferred type is
+ // `dynamic`, but the inferred type of the initializer is `bottom`.
+ // TODO(paulberry): Is this intentional/desirable?
+ var mainUnit = checkFile('''
+var v = null;
+''');
+ var v = mainUnit.topLevelVariables[0];
+ expect(v.type.toString(), 'dynamic');
+ expect(v.initializer.type.toString(), '() → <bottom>');
+ }
+
+ void test_bottom_inClosure() {
+ // When a closure's return type is inferred from the expression `null`, the
+ // inferred type is `dynamic`.
+ var mainUnit = checkFile('''
+var v = () => null;
+''');
+ var v = mainUnit.topLevelVariables[0];
+ expect(v.type.toString(), '() → dynamic');
+ expect(v.initializer.type.toString(), '() → () → dynamic');
+ }
+
void test_canInferAlsoFromStaticAndInstanceFieldsFlagOn() {
addFile(
'''
« 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