Fix for NPE when prefix completion after an expression without type.

R=brianwilkerson@google.com

Change-Id: I3ef1c1e1f981e3a5c9ed6da066a1d204c6b3816d
Reviewed-on: https://dart-review.googlesource.com/71620
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
This commit is contained in:
Konstantin Shcheglov 2018-08-27 22:14:01 +00:00 committed by commit-bot@chromium.org
parent d332cae86e
commit 83324a8db9
2 changed files with 10 additions and 0 deletions

View file

@ -563,6 +563,7 @@ class PostfixCompletionProcessor {
}
Expression expr = list.firstWhere((expr) {
DartType type = expr.staticType;
if (type == null) return false;
if (type.isSubtypeOf(builtInType)) return true;
Element element = type.element;
if (element is TypeDefiningElement) {

View file

@ -332,6 +332,15 @@ f(List expr) {
''');
}
test_if_invalid_importPrefix() async {
await _assertNotApplicable('.if', '''
import 'dart:async' as p;
f() {
p.if
}
''');
}
test_ifDynamic() async {
await _prepareCompletion('.if', '''
f(expr) {