Ignore not ClassDeclaration target of an unknown method invocation.

R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org/1764743002 .
This commit is contained in:
Konstantin Shcheglov 2016-03-03 11:23:32 -08:00
parent 7c2c02d6a6
commit adcf43968f
2 changed files with 17 additions and 3 deletions

View file

@ -1990,13 +1990,17 @@ class FixProcessor {
}
ClassElement targetClassElement = targetType.element as ClassElement;
targetElement = targetClassElement;
// may be static
// prepare target ClassDeclaration
AstNode targetTypeNode = getParsedClassElementNode(targetClassElement);
if (targetTypeNode is! ClassDeclaration) {
return;
}
ClassDeclaration targetClassNode = targetTypeNode;
// maybe static
if (target is Identifier) {
staticModifier = target.bestElement.kind == ElementKind.CLASS;
}
// prepare insert offset
ClassDeclaration targetClassNode =
getParsedClassElementNode(targetClassElement);
prefix = ' ';
insertOffset = targetClassNode.end - 1;
if (targetClassNode.members.isEmpty) {

View file

@ -4341,6 +4341,16 @@ main() {
await assertNoFix(DartFixKind.CREATE_METHOD);
}
test_undefinedMethod_create_BAD_targetIsEnum() async {
resolveTestUnit('''
enum MyEnum {A, B}
main() {
MyEnum.foo();
}
''');
await assertNoFix(DartFixKind.CREATE_METHOD);
}
test_undefinedMethod_create_generic_BAD_argumentType() async {
resolveTestUnit('''
class A<T> {