Stop visiting comments and convert NPEs to more meaningful errors

Change-Id: Idcebed220dbcd8fcb1613fce891387f88ee4d442
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/107063
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 aee7dcf..45e2dd1 100644
--- a/pkg/nnbd_migration/lib/src/graph_builder.dart
+++ b/pkg/nnbd_migration/lib/src/graph_builder.dart
@@ -275,6 +275,12 @@
   }
 
   @override
+  DecoratedType visitComment(Comment node) {
+    // Ignore comments.
+    return null;
+  }
+
+  @override
   DecoratedType visitConditionalExpression(ConditionalExpression node) {
     _handleAssignment(_notNullType, node.condition);
     // TODO(paulberry): guard anything inside the true and false branches
@@ -317,6 +323,12 @@
 
   @override
   DecoratedType visitExpressionFunctionBody(ExpressionFunctionBody node) {
+    if (_currentFunctionType == null) {
+      _unimplemented(
+          node,
+          'ExpressionFunctionBody with no current function '
+          '(parent is ${node.parent.runtimeType})');
+    }
     _handleAssignment(_currentFunctionType.returnType, node.expression);
     return null;
   }
@@ -756,11 +768,13 @@
           DecoratedType bound;
           bound = _variables.decoratedElementType(element.typeParameters[i],
               create: true);
-          _checkAssignment(
-              bound,
-              _variables.decoratedTypeAnnotation(_source, typeArguments[i]),
-              null,
-              hard: true);
+          var argumentType =
+              _variables.decoratedTypeAnnotation(_source, typeArguments[i]);
+          if (argumentType == null) {
+            _unimplemented(typeName,
+                'No decorated type for type argument ${typeArguments[i]} ($i)');
+          }
+          _checkAssignment(bound, argumentType, null, hard: true);
         }
       }
     }