Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 311700
b: refs/heads/main
c: 1b8a3b1
h: refs/heads/main
  • Loading branch information
scheglov authored and [email protected] committed May 7, 2018
1 parent 2634e17 commit 7271367
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 8 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
Expand Up @@ -1994,4 +1994,4 @@ refs/tags/2.14.0-96.0.dev: 1eee24e50fc3028754d9a8e98852b949c04da4e4
refs/tags/2.14.0-97.0.dev: ba9c1636e87fbdcc02b8bc4a584455c32f8378b4
refs/tags/2.14.0-98.0.dev: f2d370c93582bbf4da42b5dd4c906d6145b01ea9
refs/tags/2.14.0-99.0.dev: e722f62b48fb382534efc1f20735def68848006f
refs/heads/main: 6c301a4e32089b7ec55b10c1a41efaa8c0c762e0
refs/heads/main: 1b8a3b104593f39a188e5ab074053b4b4113873d
17 changes: 10 additions & 7 deletions trunk/pkg/analysis_server/lib/src/computer/computer_overrides.dart
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ class _OverriddenElementsFinder {
*/
OverriddenElements find() {
_visited.clear();
_addSuperOverrides(_class.supertype);
_addSuperOverrides(_class.type, withThisType: false);
_visited.clear();
_addInterfaceOverrides(_class.type, false);
_superElements.forEach(_interfaceElements.remove);
Expand Down Expand Up @@ -189,20 +189,23 @@ class _OverriddenElementsFinder {
_addInterfaceOverrides(type.superclass, checkType);
}

void _addSuperOverrides(InterfaceType type) {
void _addSuperOverrides(InterfaceType type, {bool withThisType: true}) {
if (type == null) {
return;
}
if (!_visited.add(type)) {
return;
}
// this type
Element element = _lookupMember(type.element);
if (element != null && !_superElements.contains(element)) {
_superElements.add(element);

if (withThisType) {
Element element = _lookupMember(type.element);
if (element != null && !_superElements.contains(element)) {
_superElements.add(element);
}
}
// super

_addSuperOverrides(type.superclass);
type.mixins.forEach(_addSuperOverrides);
}

Element _lookupMember(ClassElement classElement) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,55 @@ class C extends A implements A {
expect(override.interfaceMembers, isNull);
}

test_mixin_method_direct() async {
addTestFile('''
class A {
m() {} // in A
}
class B extends Object with A {
m() {} // in B
}
''');
await prepareOverrides();
assertHasOverride('m() {} // in B');
assertHasSuperElement('m() {} // in A');
assertNoInterfaceMembers();
}

test_mixin_method_indirect() async {
addTestFile('''
class A {
m() {} // in A
}
class B extends A {
}
class C extends Object with B {
m() {} // in C
}
''');
await prepareOverrides();
assertHasOverride('m() {} // in C');
assertHasSuperElement('m() {} // in A');
assertNoInterfaceMembers();
}

test_mixin_method_indirect2() async {
addTestFile('''
class A {
m() {} // in A
}
class B extends Object with A {
}
class C extends B {
m() {} // in C
}
''');
await prepareOverrides();
assertHasOverride('m() {} // in C');
assertHasSuperElement('m() {} // in A');
assertNoInterfaceMembers();
}

test_staticMembers() async {
addTestFile('''
class A {
Expand Down

0 comments on commit 7271367

Please sign in to comment.