Migration: properly handle a field overriding a field in a mixin.

Bug: https://b.corp.google.com/issues/246998513
Change-Id: Idcf496ee2957e80592fe22a016ca206b11274778
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/259659
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
This commit is contained in:
Paul Berry 2022-09-19 17:11:51 +00:00 committed by Commit Bot
parent bace4c0b8a
commit 7db67f3353
2 changed files with 24 additions and 1 deletions

View file

@ -2851,7 +2851,8 @@ class EdgeBuilder extends GeneralizingAstVisitor<DecoratedType>
ClassElement classElement,
Element overriddenElement) {
overriddenElement = overriddenElement.declaration!;
var overriddenClass = overriddenElement.enclosingElement3 as ClassElement;
var overriddenClass =
overriddenElement.enclosingElement3 as InterfaceElement;
var decoratedSupertype = _decoratedClassHierarchy!
.getDecoratedSupertype(classElement, overriddenClass);
var substitution = decoratedSupertype.asSubstitution;

View file

@ -4194,6 +4194,28 @@ class C {
await _checkSingleFileChanges(content, expected);
}
Future<void> test_field_overrides_field_in_mixin() async {
var content = '''
class C extends Object with M {
int x;
}
mixin M {
int x;
}
''';
var expected = '''
class C extends Object with M {
int? x;
}
mixin M {
int? x;
}
''';
await _checkSingleFileChanges(content, expected);
}
Future<void> test_field_overrides_getter() async {
var content = '''
abstract class C {