Skip to content

Commit 9482f95

Browse files
scheglovCommit Queue
authored andcommitted
Fine. Fill interfaces of supertypes before subtypes.
So, that we can find synthetic top-merged members. Change-Id: Ic8e90fe5c3a8ee44730f9c3acde0a7618bcca563 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429821 Commit-Queue: Konstantin Shcheglov <[email protected]> Reviewed-by: Johnni Winther <[email protected]>
1 parent 9907c35 commit 9482f95

File tree

2 files changed

+427
-4
lines changed

2 files changed

+427
-4
lines changed

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

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import 'dart:typed_data';
77
import 'package:analyzer/dart/element/element.dart';
88
import 'package:analyzer/src/dart/analysis/file_state.dart';
99
import 'package:analyzer/src/dart/element/element.dart';
10+
import 'package:analyzer/src/dart/element/type.dart';
1011
import 'package:analyzer/src/fine/lookup_name.dart';
1112
import 'package:analyzer/src/fine/manifest_context.dart';
1213
import 'package:analyzer/src/fine/manifest_id.dart';
@@ -742,13 +743,39 @@ class LibraryManifestBuilder {
742743
}
743744

744745
void _fillInterfaceElementsInterface() {
746+
var librarySet = libraryElements.toSet();
747+
var interfaceSet = <InterfaceElementImpl2>{};
748+
749+
void addInterfacesToFill(InterfaceElementImpl2 element) {
750+
// If not in this bundle, it has interface ready.
751+
if (!librarySet.contains(element.library2)) {
752+
return;
753+
}
754+
755+
// Ensure that we have interfaces of supertypes first.
756+
for (var superType in element.allSupertypes) {
757+
superType as InterfaceTypeImpl;
758+
addInterfacesToFill(superType.element3);
759+
}
760+
761+
interfaceSet.add(element);
762+
}
763+
745764
for (var libraryElement in libraryElements) {
746765
for (var element in libraryElement.children2) {
747766
if (element is InterfaceElementImpl2) {
748-
_fillInterfaceElementInterface(element);
767+
addInterfacesToFill(element);
749768
}
750769
}
751770
}
771+
772+
// Fill interfaces of supertypes before interfaces of subtypes.
773+
// So that if there are synthetic top-merged members in interfaces of
774+
// supertypes (these members are not included into declared), we can
775+
// get corresponding IDs.
776+
for (var element in interfaceSet) {
777+
_fillInterfaceElementInterface(element);
778+
}
752779
}
753780

754781
void _fillItemMapFromInputManifests({
@@ -850,11 +877,23 @@ class LibraryManifestBuilder {
850877
// SAFETY: null asserts are safe, because element is in this library.
851878
switch (element) {
852879
case GetterElementImpl():
853-
return enclosingItem.declaredGetters[lookupName]!.id;
880+
var declaredGetter = enclosingItem.declaredGetters[lookupName];
881+
if (declaredGetter != null) {
882+
return declaredGetter.id;
883+
}
884+
return enclosingItem.interface.map[lookupName]!;
854885
case SetterElementImpl():
855-
return enclosingItem.declaredSetters[lookupName]!.id;
886+
var declaredSetter = enclosingItem.declaredSetters[lookupName];
887+
if (declaredSetter != null) {
888+
return declaredSetter.id;
889+
}
890+
return enclosingItem.interface.map[lookupName]!;
856891
case MethodElementImpl2():
857-
return enclosingItem.declaredMethods[lookupName]!.id;
892+
var declaredMethod = enclosingItem.declaredMethods[lookupName];
893+
if (declaredMethod != null) {
894+
return declaredMethod.id;
895+
}
896+
return enclosingItem.interface.map[lookupName]!;
858897
case ConstructorElementImpl2():
859898
if (enclosingItem.declaredConstructors[lookupName] case var item?) {
860899
return item.id;

0 commit comments

Comments
 (0)