Convert some NPEs into explicit throws and add the missing visit methods discovered by doing so

Change-Id: I0613614168a7373a460d05cf8470f9b59264de0b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/105970
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 9dc042c..444b7f4 100644
--- a/pkg/nnbd_migration/lib/src/graph_builder.dart
+++ b/pkg/nnbd_migration/lib/src/graph_builder.dart
@@ -174,6 +174,11 @@
   }
 
   @override
+  DecoratedType visitAwaitExpression(AwaitExpression node) {
+    throw new UnimplementedError('TODO(brianwilkerson)');
+  }
+
+  @override
   DecoratedType visitBinaryExpression(BinaryExpression node) {
     switch (node.operator.type) {
       case TokenType.EQ_EQ:
@@ -371,6 +376,11 @@
   }
 
   @override
+  DecoratedType visitListLiteral(ListLiteral node) {
+    throw new UnimplementedError('TODO(brianwilkerson)');
+  }
+
+  @override
   DecoratedType visitMethodDeclaration(MethodDeclaration node) {
     node.parameters?.accept(this);
     assert(_currentFunctionType == null);
@@ -451,6 +461,11 @@
   }
 
   @override
+  DecoratedType visitPrefixExpression(PrefixExpression node) {
+    throw new UnimplementedError('TODO(brianwilkerson)');
+  }
+
+  @override
   DecoratedType visitPropertyAccess(PropertyAccess node) {
     return _handlePropertyAccess(node, node.realTarget, node.propertyName);
   }
@@ -485,6 +500,11 @@
   }
 
   @override
+  DecoratedType visitSuperExpression(SuperExpression node) {
+    throw new UnimplementedError('TODO(brianwilkerson)');
+  }
+
+  @override
   DecoratedType visitThisExpression(ThisExpression node) {
     return DecoratedType(node.staticType, _graph.never);
   }
@@ -599,6 +619,10 @@
       DecoratedType destinationType, Expression expression,
       {bool canInsertChecks = true}) {
     var sourceType = expression.accept(this);
+    if (sourceType == null) {
+      throw StateError('No type computed for ${expression.runtimeType} '
+          '(${expression.toSource()}) offset=${expression.offset}');
+    }
     _checkAssignment(
         destinationType, sourceType, canInsertChecks ? expression : null);
     return sourceType;
diff --git a/pkg/nnbd_migration/lib/src/node_builder.dart b/pkg/nnbd_migration/lib/src/node_builder.dart
index f7abe82..063825f 100644
--- a/pkg/nnbd_migration/lib/src/node_builder.dart
+++ b/pkg/nnbd_migration/lib/src/node_builder.dart
@@ -80,12 +80,27 @@
     if (node.declaredElement.hasRequired || node.defaultValue != null) {
       return null;
     }
+    if (decoratedType == null) {
+      throw StateError('No type computed for ${node.parameter.runtimeType} '
+          '(${node.parent.parent.toSource()}) offset=${node.offset}');
+    }
     decoratedType.node.trackPossiblyOptional();
     _variables.recordPossiblyOptional(_source, node, decoratedType.node);
     return null;
   }
 
   @override
+  DecoratedType visitFieldFormalParameter(FieldFormalParameter node) {
+    throw new UnimplementedError('TODO(brianwilkerson)');
+  }
+
+  @override
+  DecoratedType visitFunctionTypedFormalParameter(
+      FunctionTypedFormalParameter node) {
+    throw new UnimplementedError('TODO(brianwilkerson)');
+  }
+
+  @override
   DecoratedType visitFormalParameter(FormalParameter node) {
     // Do not visit children
     // TODO(paulberry): handle all types of formal parameters