Skip to content

Commit

Permalink
Migration: create flow anaylsis before visiting parameters.
Browse files Browse the repository at this point in the history
This is necessary in case any parameters are found that trigger flow
analysis methods to be called.

Should address ~24 exceptions whose stack trace contains the line:

EdgeBuilder.visitBooleanLiteral (package:nnbd_migration/src/edge_builder.dart:390:19)

Change-Id: I08dc31a8acdaaf0685516aab872905f620602806
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/116488
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
  • Loading branch information
stereotype441 authored and commit-bot@chromium.org committed Sep 10, 2019
1 parent 1100aab commit 79137ed
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/nnbd_migration/lib/src/edge_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1647,9 +1647,9 @@ class EdgeBuilder extends GeneralizingAstVisitor<DecoratedType>
assert(_currentFunctionType == null);
metadata.accept(this);
returnType?.accept(this);
_createFlowAnalysis(body);
parameters?.accept(this);
_currentFunctionType = _variables.decoratedElementType(declaredElement);
_createFlowAnalysis(body);
_addParametersToFlowAnalysis(parameters);
// Push a scope of post-dominated declarations on the stack.
_postDominatedLocals.pushScope(elements: declaredElement.parameters);
Expand Down
9 changes: 9 additions & 0 deletions pkg/nnbd_migration/test/edge_builder_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1439,6 +1439,15 @@ int f(bool b, int i) {
assertLUB(nullable_conditional, nullable_i, always);
}

test_constructor_default_parameter_value_bool() async {
await analyze('''
class C {
C([bool b = true]);
}
''');
assertNoUpstreamNullability(decoratedTypeAnnotation('bool b').node);
}

test_constructor_named() async {
await analyze('''
class C {
Expand Down

0 comments on commit 79137ed

Please sign in to comment.