Add support for double literals
Change-Id: I08ea12bb0213272b192d063fd3699b2495912077
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/106140
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
diff --git a/pkg/nnbd_migration/lib/src/graph_builder.dart b/pkg/nnbd_migration/lib/src/graph_builder.dart
index 2f3ba2a..80160c2 100644
--- a/pkg/nnbd_migration/lib/src/graph_builder.dart
+++ b/pkg/nnbd_migration/lib/src/graph_builder.dart
@@ -278,7 +278,7 @@
@override
DecoratedType visitDoubleLiteral(DoubleLiteral node) {
- throw new UnimplementedError('TODO(brianwilkerson)');
+ return DecoratedType(node.staticType, _graph.never);
}
@override
diff --git a/pkg/nnbd_migration/test/migration_visitor_test.dart b/pkg/nnbd_migration/test/migration_visitor_test.dart
index 3b910ba..e44e273 100644
--- a/pkg/nnbd_migration/test/migration_visitor_test.dart
+++ b/pkg/nnbd_migration/test/migration_visitor_test.dart
@@ -447,6 +447,15 @@
assertConditional(nullable_conditional, nullable_i, always);
}
+ test_doubleLiteral() async {
+ await analyze('''
+double f() {
+ return 1.0;
+}
+''');
+ assertNoUpstreamNullability(decoratedTypeAnnotation('double').node);
+ }
+
test_functionDeclaration_expression_body() async {
await analyze('''
int/*1*/ f(int/*2*/ i) => i/*3*/;
@@ -833,7 +842,7 @@
hard: true);
}
- test_intLiteral() async {
+ test_integerLiteral() async {
await analyze('''
int f() {
return 0;