Skip to content

Commit aa63628

Browse files
scheglovcommit-bot@chromium.org
authored andcommitted
Don't do TOP_MERGE when computing inheritedMap.
Bug: #41470 Change-Id: I9a97ab0b505e4614a338ae20c011ccef7f9026c2 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/143382 Reviewed-by: Brian Wilkerson <[email protected]> Reviewed-by: Janice Collins <[email protected]> Commit-Queue: Konstantin Shcheglov <[email protected]>
1 parent 6d88b04 commit aa63628

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

pkg/analyzer/lib/src/dart/element/inheritance_manager3.dart

+14-4
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ class InheritanceManager3 {
7575
type.element,
7676
interface._inheritedMap,
7777
interface._overridden,
78+
doTopMerge: false,
7879
);
7980
}
8081
return interface._inheritedMap;
@@ -137,6 +138,7 @@ class InheritanceManager3 {
137138
classElement,
138139
superClass,
139140
superClassCandidates,
141+
doTopMerge: true,
140142
);
141143
superImplemented.add(superClass);
142144
} else {
@@ -210,6 +212,7 @@ class InheritanceManager3 {
210212
classElement,
211213
map,
212214
candidatesFromSuperAndMixin,
215+
doTopMerge: true,
213216
);
214217
for (var entry in map.entries) {
215218
namedCandidates[entry.key] = [entry.value];
@@ -260,6 +263,7 @@ class InheritanceManager3 {
260263
classElement,
261264
map,
262265
namedCandidates,
266+
doTopMerge: true,
263267
);
264268

265269
var noSuchMethodForwarders = <Name>{};
@@ -446,9 +450,11 @@ class InheritanceManager3 {
446450
/// such single most specific signature (i.e. no valid override), then add a
447451
/// new conflict description.
448452
List<Conflict> _findMostSpecificFromNamedCandidates(
449-
ClassElement targetClass,
450-
Map<Name, ExecutableElement> map,
451-
Map<Name, List<ExecutableElement>> namedCandidates) {
453+
ClassElement targetClass,
454+
Map<Name, ExecutableElement> map,
455+
Map<Name, List<ExecutableElement>> namedCandidates, {
456+
@required bool doTopMerge,
457+
}) {
452458
TypeSystemImpl typeSystem = targetClass.library.typeSystem;
453459

454460
List<Conflict> conflicts;
@@ -498,7 +504,11 @@ class InheritanceManager3 {
498504
continue;
499505
}
500506

501-
map[name] = _topMerge(typeSystem, targetClass, validOverrides);
507+
if (doTopMerge) {
508+
map[name] = _topMerge(typeSystem, targetClass, validOverrides);
509+
} else {
510+
map[name] = validOverrides.first;
511+
}
502512
}
503513

504514
return conflicts;

pkg/analyzer/test/src/dart/element/inheritance_manager3_test.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -1075,7 +1075,7 @@ class C implements A, B {
10751075
''');
10761076

10771077
_assertInheritedMap('C', r'''
1078-
B.foo: void Function({required int a})
1078+
A.foo: void Function({int a})
10791079
''');
10801080
}
10811081

0 commit comments

Comments
 (0)