Fix npe in quick fix computation (issue 32926)

Change-Id: Ic93da063758513f101d753516cb61c351dae2501
Reviewed-on: https://dart-review.googlesource.com/51940
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Danny Tuppeny <dantup@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
This commit is contained in:
Brian Wilkerson 2018-04-19 17:05:20 +00:00 committed by commit-bot@chromium.org
parent 499b6ba4cf
commit bdc727d49b
2 changed files with 12 additions and 1 deletions

View file

@ -2393,7 +2393,7 @@ class FixProcessor {
final thisExpression = node is ThisExpression
? node
: node.getAncestor((node) => node is ThisExpression);
final parent = thisExpression.parent;
final parent = thisExpression?.parent;
if (parent is PropertyAccess) {
DartChangeBuilder changeBuilder = new DartChangeBuilder(session);
await changeBuilder.addFileEdit(file, (DartFileEditBuilder builder) {

View file

@ -6901,6 +6901,17 @@ class A {
''');
}
test_removeThisExpression_notAThisExpression() async {
String src = '''
void foo() {
final /*LINT*/this.id;
}
''';
await findLint(src, LintNames.unnecessary_this);
await assertNoFix(DartFixKind.REMOVE_THIS_EXPRESSION);
}
test_removeThisExpression_propertyAccess_oneCharacterOperator() async {
String src = '''
class A {