update NodeBuilder for default value type arguments

This updates NodeBuilder to build nodes for type arguments
in default parameter values.

Change-Id: I8999bdfca9a60d9e1d3feff5cdbd1cdc62cdb4fd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/108120
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Dan Rubel <danrubel@google.com>
diff --git a/pkg/nnbd_migration/lib/src/node_builder.dart b/pkg/nnbd_migration/lib/src/node_builder.dart
index 2f4563e..43c9143 100644
--- a/pkg/nnbd_migration/lib/src/node_builder.dart
+++ b/pkg/nnbd_migration/lib/src/node_builder.dart
@@ -146,7 +146,10 @@
   @override
   DecoratedType visitDefaultFormalParameter(DefaultFormalParameter node) {
     var decoratedType = node.parameter.accept(this);
-    if (node.declaredElement.hasRequired || node.defaultValue != null) {
+    if (node.defaultValue != null) {
+      node.defaultValue.accept(this);
+      return null;
+    } else if (node.declaredElement.hasRequired) {
       return null;
     }
     if (decoratedType == null) {
diff --git a/pkg/nnbd_migration/lib/src/variables.dart b/pkg/nnbd_migration/lib/src/variables.dart
index fce9b77..ccb4aec 100644
--- a/pkg/nnbd_migration/lib/src/variables.dart
+++ b/pkg/nnbd_migration/lib/src/variables.dart
@@ -48,7 +48,13 @@
       throw StateError('No declarated type annotations in ${source.fullName}; '
           'expected one for ${typeAnnotation.toSource()}');
     }
-    return annotationsInSource[_uniqueOffsetForTypeAnnotation(typeAnnotation)];
+    DecoratedTypeAnnotation decoratedTypeAnnotation =
+        annotationsInSource[_uniqueOffsetForTypeAnnotation(typeAnnotation)];
+    if (decoratedTypeAnnotation == null) {
+      throw StateError('Missing declarated type annotation'
+          ' in ${source.fullName}; for ${typeAnnotation.toSource()}');
+    }
+    return decoratedTypeAnnotation;
   }
 
   Map<Source, List<PotentialModification>> getPotentialModifications() =>
diff --git a/pkg/nnbd_migration/test/edge_builder_test.dart b/pkg/nnbd_migration/test/edge_builder_test.dart
index ec97dbd..229a53a 100644
--- a/pkg/nnbd_migration/test/edge_builder_test.dart
+++ b/pkg/nnbd_migration/test/edge_builder_test.dart
@@ -1042,6 +1042,17 @@
             hard: true));
   }
 
+  test_functionDeclaration_parameter_named_default_listConst() async {
+    await analyze('''
+void f({List<int/*1*/> i = const <int/*2*/>[]}) {}
+''');
+
+    assertNoUpstreamNullability(decoratedTypeAnnotation('List<int/*1*/>').node);
+    assertEdge(decoratedTypeAnnotation('int/*2*/').node,
+        decoratedTypeAnnotation('int/*1*/').node,
+        hard: false);
+  }
+
   test_functionDeclaration_parameter_named_default_notNull() async {
     await analyze('''
 void f({int i = 1}) {}