Migration: properly handle accesses to getters in mixins.

Bug: https://b.corp.google.com/issues/246998513
Change-Id: I8ca1fe87f256dbf4f31fca9bd3f555d1def4bb3c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/260446
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
This commit is contained in:
Paul Berry 2022-09-22 12:26:17 +00:00 committed by Commit Bot
parent 78dd98a8f4
commit 872e4c5696
2 changed files with 19 additions and 1 deletions

View file

@ -286,7 +286,7 @@ class EdgeBuilder extends GeneralizingAstVisitor<DecoratedType>
Element? baseElement = element.declaration;
if (targetType != null) {
var enclosingElement = baseElement!.enclosingElement3;
if (enclosingElement is ClassElement) {
if (enclosingElement is InterfaceElement) {
if (targetType.type.explicitBound is InterfaceType &&
enclosingElement.typeParameters.isNotEmpty) {
substitution = _decoratedClassHierarchy!

View file

@ -8777,6 +8777,24 @@ main() {
await _checkSingleFileChanges(content, expected);
}
Future<void> test_reference_to_mixin_getter() async {
var content = '''
mixin M {
Object f() => this.x;
Object get x => null;
}
''';
var expected = '''
mixin M {
Object? f() => this.x;
Object? get x => null;
}
''';
await _checkSingleFileChanges(content, expected);
}
Future<void> test_regression_40551() async {
var content = '''
class B<T extends Object> { // bound should not be made nullable