Fix for crash when reporting ABSTRACT_SUPER_MEMBER_REFERENCE for PropertyAccess in mixin.

Change-Id: I3270ac34b837fc5940e6f4938627bb7479eff851
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/146920
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
Konstantin Shcheglov 2020-05-06 19:27:58 +00:00 committed by commit-bot@chromium.org
parent a85c8b7520
commit e6a3125492
2 changed files with 27 additions and 9 deletions

View file

@ -1410,15 +1410,11 @@ class ElementResolver extends SimpleAstVisitor<void> {
_resolver.inheritance.getInherited2(staticType.element, name);
if (element != null) {
propertyName.staticElement = element;
ClassElementImpl receiverSuperClass =
staticType.element.supertype.element;
if (!receiverSuperClass.hasNoSuchMethod) {
_errorReporter.reportErrorForNode(
CompileTimeErrorCode.ABSTRACT_SUPER_MEMBER_REFERENCE,
propertyName,
[element.kind.displayName, propertyName.name],
);
}
_errorReporter.reportErrorForNode(
CompileTimeErrorCode.ABSTRACT_SUPER_MEMBER_REFERENCE,
propertyName,
[element.kind.displayName, propertyName.name],
);
} else {
_errorReporter.reportErrorForNode(
StaticTypeWarningCode.UNDEFINED_SUPER_GETTER,

View file

@ -211,6 +211,28 @@ abstract class B extends A {
);
}
test_propertyAccess_getter_mixin_implements() async {
await assertErrorsInCode(r'''
class A {
int get foo => 0;
}
mixin M implements A {
void bar() {
super.foo;
}
}
''', [
error(CompileTimeErrorCode.ABSTRACT_SUPER_MEMBER_REFERENCE, 81, 3),
]);
assertPropertyAccess2(
findNode.propertyAccess('super.foo'),
element: findElement.getter('foo', of: 'A'),
type: 'int',
);
}
test_propertyAccess_getter_mixinHasNoSuchMethod() async {
await assertErrorsInCode('''
class A {