Skip to content

Commit 5ae5470

Browse files
scheglovCommit Queue
authored andcommitted
Fine. Don't include inherited private members.
When they are from different libraries, they can create conflicts. But we don't need them even when they are from the same library. If a library changes, we analyze its files anyway. Change-Id: I4e57ebb605953694982b40f4a8e9a1c75dd87bc0 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/424902 Reviewed-by: Paul Berry <[email protected]> Commit-Queue: Konstantin Shcheglov <[email protected]>
1 parent b91e756 commit 5ae5470

File tree

2 files changed

+792
-74
lines changed

2 files changed

+792
-74
lines changed

pkg/analyzer/lib/src/fine/library_manifest.dart

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -214,34 +214,40 @@ class LibraryManifestBuilder {
214214
// Must be created already.
215215
var item = declaredItems[element] as InterfaceItem;
216216

217-
var map = element.inheritanceManager.getInterface2(element).map2;
218-
for (var entry in map.entries) {
219-
var executable = entry.value.baseElement;
220-
221-
// Add only inherited.
222-
if (executable.enclosingElement2 == element) {
223-
continue;
224-
}
217+
var interface = element.inheritanceManager.getInterface2(element);
218+
var inheritedExecutables = interface.map2.values
219+
.map((e) => e.baseElement)
220+
.where((e) => e.enclosingElement2 != element)
221+
.toList(growable: false);
225222

226-
var lookupName = executable.lookupName?.asLookupName;
227-
if (lookupName == null) {
228-
continue;
229-
}
223+
for (var kindIndex = 0; kindIndex < 3; kindIndex++) {
224+
for (var executable in inheritedExecutables) {
225+
var lookupName = executable.lookupName?.asLookupName;
226+
if (lookupName == null) {
227+
continue;
228+
}
230229

231-
var id = _getInterfaceElementMemberId(executable);
230+
// We can see a private member only inside the library.
231+
// But we reanalyze the library when one of its files changes.
232+
if (lookupName.isPrivate) {
233+
continue;
234+
}
232235

233-
var baseName = lookupName.asBaseName;
234-
switch (executable) {
235-
case MethodElementImpl2():
236-
if (lookupName.isIndexEq) {
237-
item.members.addInheritedIndexEq(baseName, id);
238-
} else {
239-
item.members.addInheritedMethod(baseName, id);
240-
}
241-
case GetterElementImpl():
242-
item.members.addInheritedGetter(baseName, id);
243-
case SetterElementImpl():
244-
item.members.addInheritedSetter(baseName, id);
236+
var baseName = lookupName.asBaseName;
237+
var id = _getInterfaceElementMemberId(executable);
238+
239+
switch ((kindIndex, executable)) {
240+
case (0, MethodElementImpl2()):
241+
if (lookupName.isIndexEq) {
242+
item.members.addInheritedIndexEq(baseName, id);
243+
} else {
244+
item.members.addInheritedMethod(baseName, id);
245+
}
246+
case (1, GetterElementImpl()):
247+
item.members.addInheritedGetter(baseName, id);
248+
case (2, SetterElementImpl()):
249+
item.members.addInheritedSetter(baseName, id);
250+
}
245251
}
246252
}
247253
}

0 commit comments

Comments
 (0)