Skip to content

Commit

Permalink
Migration: handle prefixed class references.
Browse files Browse the repository at this point in the history
Should address ~48 exceptions whose stack trace includes the line:

Variables._createDecoratedElementType (package:nnbd_migration/src/variables.dart:230:7)

Change-Id: I13b89f347fc91fcca23392cf14dfd6c2876704f0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/116042
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
  • Loading branch information
stereotype441 authored and commit-bot@chromium.org committed Sep 6, 2019
1 parent 0d63ce1 commit d7c96f3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/nnbd_migration/lib/src/edge_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1799,6 +1799,11 @@ class EdgeBuilder extends GeneralizingAstVisitor<DecoratedType>
// Dynamic dispatch.
return _dynamicType;
}
if (callee is ClassElement) {
// Not a real call; just a prefixed reference to a class name.
assert(_isPrefix(target));
return _nonNullableTypeType;
}
var calleeType = getOrComputeElementType(callee, targetType: targetType);
// TODO(paulberry): substitute if necessary
if (propertyName.inSetterContext()) {
Expand Down
18 changes: 18 additions & 0 deletions pkg/nnbd_migration/test/edge_builder_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4260,6 +4260,16 @@ int f() => null;
assertEdge(always, decoratedTypeAnnotation('int').node, hard: false);
}

test_static_method_call_prefixed() async {
await analyze('''
import 'dart:async' as a;
void f(void Function() callback) {
a.Timer.run(callback);
}
''');
// No assertions. Just making sure this doesn't crash.
}

test_stringLiteral() async {
// TODO(paulberry): also test string interpolations
await analyze('''
Expand Down Expand Up @@ -4415,6 +4425,14 @@ Type f() {
assertNoUpstreamNullability(decoratedTypeAnnotation('Type').node);
}

test_typeName_prefixed() async {
await analyze('''
import 'dart:async' as a;
Type f() => a.Future;
''');
assertEdge(never, decoratedTypeAnnotation('Type').node, hard: false);
}

test_typeName_union_with_bound() async {
await analyze('''
class C<T extends Object> {}
Expand Down

0 comments on commit d7c96f3

Please sign in to comment.