skip directives during nnbd migration
Currently, the migration engine crashes when it visits the identifier
in the following directive:
import "dart:core" as one;
This updates the migration engine to skip directives when looking
for expressions and type annotations to be migrated.
Change-Id: I079263b13e5f4c75fbfe22fa06993e7a5d4f9c16
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/106660
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Dan Rubel <danrubel@google.com>
diff --git a/pkg/nnbd_migration/lib/src/graph_builder.dart b/pkg/nnbd_migration/lib/src/graph_builder.dart
index 6ccfb93..4ced40b 100644
--- a/pkg/nnbd_migration/lib/src/graph_builder.dart
+++ b/pkg/nnbd_migration/lib/src/graph_builder.dart
@@ -484,6 +484,12 @@
}
@override
+ DecoratedType visitNamespaceDirective(NamespaceDirective node) {
+ // skip directives
+ return null;
+ }
+
+ @override
DecoratedType visitNode(AstNode node) {
if (listener != null) {
try {
diff --git a/pkg/nnbd_migration/test/graph_builder_test.dart b/pkg/nnbd_migration/test/graph_builder_test.dart
index e5305ea..71cd99b 100644
--- a/pkg/nnbd_migration/test/graph_builder_test.dart
+++ b/pkg/nnbd_migration/test/graph_builder_test.dart
@@ -1435,6 +1435,15 @@
hard: true);
}
+ test_skipDirectives() async {
+ await analyze('''
+import "dart:core" as one;
+main() {}
+''');
+ // No test expectations.
+ // Just verifying that the test passes
+ }
+
test_soft_edge_for_non_variable_reference() async {
// Edges originating in things other than variable references should be
// soft.