Skip to content

Commit

Permalink
Migration: handle upcasts from function type to Function or Object.
Browse files Browse the repository at this point in the history
This should address ~91 exceptions with this line in the stacktrace:

_AssignmentChecker._checkAssignment_recursion (package:nnbd_migration/src/edge_builder.dart:2031:7)

Change-Id: Id837ffb3eea207dd1f63010482a69397a8dff9ad
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/115768
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
  • Loading branch information
stereotype441 authored and commit-bot@chromium.org committed Sep 6, 2019
1 parent 7e04e05 commit cdd2f85
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/nnbd_migration/lib/src/edge_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2027,6 +2027,9 @@ mixin _AssignmentChecker {
}
} else if (destinationType.isDynamic || sourceType.isDynamic) {
// ok; nothing further to do.
} else if (destinationType is InterfaceType && sourceType is FunctionType) {
// Either this is an upcast to Function or Object, or it is erroneous
// code. In either case we don't need to create any additional edges.
} else {
throw '$destination <= $source'; // TODO(paulberry)
}
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 @@ -392,6 +392,15 @@ int f(dynamic d) => d;
hard: true);
}

test_assign_function_type_to_function_interface_type() async {
await analyze('''
Function f(void Function() x) => x;
''');
assertEdge(decoratedGenericFunctionTypeAnnotation('void Function()').node,
decoratedTypeAnnotation('Function f').node,
hard: true);
}

test_assign_future_to_futureOr_complex() async {
await analyze('''
import 'dart:async';
Expand Down

0 comments on commit cdd2f85

Please sign in to comment.