Skip to content

Commit fa8f1f6

Browse files
bwilkersoncommit-bot@chromium.org
authored andcommitted
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 <[email protected]> Commit-Queue: Brian Wilkerson <[email protected]>
1 parent 56a1cfe commit fa8f1f6

1 file changed

Lines changed: 19 additions & 5 deletions

File tree

pkg/nnbd_migration/lib/src/graph_builder.dart

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,12 @@ class GraphBuilder extends GeneralizingAstVisitor<DecoratedType> {
274274
return null;
275275
}
276276

277+
@override
278+
DecoratedType visitComment(Comment node) {
279+
// Ignore comments.
280+
return null;
281+
}
282+
277283
@override
278284
DecoratedType visitConditionalExpression(ConditionalExpression node) {
279285
_handleAssignment(_notNullType, node.condition);
@@ -317,6 +323,12 @@ class GraphBuilder extends GeneralizingAstVisitor<DecoratedType> {
317323

318324
@override
319325
DecoratedType visitExpressionFunctionBody(ExpressionFunctionBody node) {
326+
if (_currentFunctionType == null) {
327+
_unimplemented(
328+
node,
329+
'ExpressionFunctionBody with no current function '
330+
'(parent is ${node.parent.runtimeType})');
331+
}
320332
_handleAssignment(_currentFunctionType.returnType, node.expression);
321333
return null;
322334
}
@@ -756,11 +768,13 @@ $stackTrace''');
756768
DecoratedType bound;
757769
bound = _variables.decoratedElementType(element.typeParameters[i],
758770
create: true);
759-
_checkAssignment(
760-
bound,
761-
_variables.decoratedTypeAnnotation(_source, typeArguments[i]),
762-
null,
763-
hard: true);
771+
var argumentType =
772+
_variables.decoratedTypeAnnotation(_source, typeArguments[i]);
773+
if (argumentType == null) {
774+
_unimplemented(typeName,
775+
'No decorated type for type argument ${typeArguments[i]} ($i)');
776+
}
777+
_checkAssignment(bound, argumentType, null, hard: true);
764778
}
765779
}
766780
}

0 commit comments

Comments
 (0)