mirror of
https://github.com/dart-lang/sdk
synced 2024-10-14 10:13:38 +00:00
nnbd_migration: fix crash on mixin override
Migration tool currently crashes if a class overrides some methods it got by adding a mixin. Added a test for that and fixed the crash, the fix boils down to casting to just `InterfaceElement` instead of `ClassElement`. Tested: added a new test Change-Id: Iab5ddb26c4930ed2020d6f3caa0710e55f24d8c2 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/275721 Commit-Queue: Ilya Yanok <yanok@google.com> Reviewed-by: Paul Berry <paulberry@google.com>
This commit is contained in:
parent
6cda72d39e
commit
822d15e7cc
|
@ -2773,7 +2773,8 @@ class EdgeBuilder extends GeneralizingAstVisitor<DecoratedType>
|
|||
ClassElement classElement,
|
||||
Element overriddenElement) {
|
||||
overriddenElement = overriddenElement.declaration!;
|
||||
var overriddenClass = overriddenElement.enclosingElement as ClassElement;
|
||||
var overriddenClass =
|
||||
overriddenElement.enclosingElement as InterfaceElement;
|
||||
var decoratedSupertype = _decoratedClassHierarchy!
|
||||
.getDecoratedSupertype(classElement, overriddenClass);
|
||||
var substitution = decoratedSupertype.asSubstitution;
|
||||
|
|
|
@ -5449,6 +5449,22 @@ class C {
|
|||
expect(hasNullCheckHint(findNode.simple('int')), isFalse);
|
||||
}
|
||||
|
||||
Future<void> test_override_mixin_method() async {
|
||||
await analyze('''
|
||||
mixin M {
|
||||
int m(int/*1*/ x);
|
||||
}
|
||||
|
||||
class C with M {
|
||||
@override
|
||||
int m(int/*2*/ x) => x;
|
||||
}
|
||||
''');
|
||||
final int1 = decoratedTypeAnnotation('int/*1*/');
|
||||
final int2 = decoratedTypeAnnotation('int/*2*/');
|
||||
assertEdge(int1.node, int2.node, hard: false, checkable: false);
|
||||
}
|
||||
|
||||
Future<void> test_override_parameter_function_typed() async {
|
||||
await analyze('''
|
||||
abstract class Base {
|
||||
|
|
Loading…
Reference in a new issue