Skip to content

Commit fa83624

Browse files
bwilkersonCommit Queue
authored andcommitted
[migration] inheritance_manager3_test.dart
Change-Id: I2ee760be480b4a8a7c8e621f0d455344f7ea9eea Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/415321 Reviewed-by: Konstantin Shcheglov <[email protected]> Commit-Queue: Brian Wilkerson <[email protected]>
1 parent 834ed5a commit fa83624

File tree

2 files changed

+405
-349
lines changed

2 files changed

+405
-349
lines changed

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

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ class CandidatesConflict extends Conflict {
2828
required super.name,
2929
required this.candidates,
3030
});
31+
32+
List<ExecutableElement2> get candidates2 =>
33+
candidates.map((e) => e.asElement2).toList();
3134
}
3235

3336
/// Failure to find a valid signature from superinterfaces.
@@ -50,6 +53,10 @@ class GetterMethodConflict extends Conflict {
5053
required this.getter,
5154
required this.method,
5255
});
56+
57+
ExecutableElement2 get getter2 => getter.asElement2;
58+
59+
ExecutableElement2 get method2 => method.asElement2;
5360
}
5461

5562
/// The extension type has both an extension and non-extension member
@@ -63,6 +70,12 @@ class HasNonExtensionAndExtensionMemberConflict extends Conflict {
6370
required this.nonExtension,
6471
required this.extension,
6572
});
73+
74+
List<ExecutableElement2> get extension2 =>
75+
extension.map((e) => e.asElement2).toList();
76+
77+
List<ExecutableElement2> get nonExtension2 =>
78+
nonExtension.map((e) => e.asElement2).toList();
6679
}
6780

6881
/// Manages knowledge about interface types and their members.
@@ -743,15 +756,29 @@ class InheritanceManager3 {
743756
return MapEntry(key, result);
744757
});
745758

759+
var implemented2 = implemented.map<Name, ExecutableElement2>(
760+
(key, value) => MapEntry(key, value.asElement2));
761+
762+
var namedCandidates2 = namedCandidates.map<Name, List<ExecutableElement2>>(
763+
(key, value) => MapEntry(key, value.map((e) => e.asElement2).toList()));
764+
765+
var superImplemented2 = superImplemented
766+
.map((e) => e.map<Name, ExecutableElement2>(
767+
(key, value) => MapEntry(key, value.asElement2)))
768+
.toList();
769+
746770
return Interface._(
747771
map: interface,
748772
declared: declared,
749773
implemented: implemented,
774+
implemented2: implemented2,
750775
noSuchMethodForwarders: noSuchMethodForwarders,
751776
overridden: namedCandidates,
777+
overridden2: namedCandidates2,
752778
redeclared: const {},
753779
redeclared2: const {},
754780
superImplemented: superImplemented,
781+
superImplemented2: superImplemented2,
755782
conflicts: conflicts.toFixedList(),
756783
);
757784
}
@@ -939,15 +966,21 @@ class InheritanceManager3 {
939966
}
940967
}
941968

969+
var implemented2 = implemented.map<Name, ExecutableElement2>(
970+
(key, value) => MapEntry(key, value.asElement2));
971+
942972
return Interface._(
943973
map: implemented,
944974
declared: declared,
945975
implemented: implemented,
976+
implemented2: implemented2,
946977
noSuchMethodForwarders: const {},
947978
overridden: const {},
979+
overridden2: const {},
948980
redeclared: uniqueRedeclared,
949981
redeclared2: uniqueRedeclared2,
950982
superImplemented: const [],
983+
superImplemented2: const [],
951984
conflicts: conflicts.toFixedList(),
952985
);
953986
}
@@ -998,15 +1031,28 @@ class InheritanceManager3 {
9981031
var implemented = <Name, ExecutableElementOrMember>{};
9991032
_addImplemented(implemented, fragment, element);
10001033

1034+
var implemented2 = implemented.map<Name, ExecutableElement2>(
1035+
(key, value) => MapEntry(key, value.asElement2));
1036+
1037+
var interfaceCandidates2 =
1038+
interfaceCandidates.map<Name, List<ExecutableElement2>>((key, value) =>
1039+
MapEntry(key, value.map((e) => e.asElement2).toList()));
1040+
1041+
var superInterface2 = superInterface.map<Name, ExecutableElement2>(
1042+
(key, value) => MapEntry(key, value.asElement2));
1043+
10011044
return Interface._(
10021045
map: interface,
10031046
declared: declared,
10041047
implemented: implemented,
1048+
implemented2: implemented2,
10051049
noSuchMethodForwarders: {},
10061050
overridden: interfaceCandidates,
1051+
overridden2: interfaceCandidates2,
10071052
redeclared: const {},
10081053
redeclared2: const {},
10091054
superImplemented: [superInterface],
1055+
superImplemented2: [superInterface2],
10101056
conflicts: <Conflict>[
10111057
...superConflicts,
10121058
...interfaceConflicts,
@@ -1226,11 +1272,14 @@ class Interface {
12261272
map: const {},
12271273
declared: const {},
12281274
implemented: const {},
1275+
implemented2: const {},
12291276
noSuchMethodForwarders: <Name>{},
12301277
overridden: const {},
1278+
overridden2: const {},
12311279
redeclared: const {},
12321280
redeclared2: const {},
12331281
superImplemented: const [{}],
1282+
superImplemented2: const [{}],
12341283
conflicts: const [],
12351284
);
12361285

@@ -1243,13 +1292,20 @@ class Interface {
12431292
/// The map of names to their concrete implementations.
12441293
final Map<Name, ExecutableElementOrMember> implemented;
12451294

1295+
/// The map of names to their concrete implementations.
1296+
final Map<Name, ExecutableElement2> implemented2;
1297+
12461298
/// The set of names that are `noSuchMethod` forwarders in [implemented].
12471299
final Set<Name> noSuchMethodForwarders;
12481300

12491301
/// The map of names to their signatures from the mixins, superclasses,
12501302
/// or interfaces.
12511303
final Map<Name, List<ExecutableElementOrMember>> overridden;
12521304

1305+
/// The map of names to their signatures from the mixins, superclasses,
1306+
/// or interfaces.
1307+
final Map<Name, List<ExecutableElement2>> overridden2;
1308+
12531309
/// The map of names to the signatures from superinterfaces that a member
12541310
/// declaration in this extension type redeclares.
12551311
final Map<Name, List<ExecutableElementOrMember>> redeclared;
@@ -1264,6 +1320,12 @@ class Interface {
12641320
/// `class C extends S with M1, M2`, we get `[S, S&M1, S&M1&M2]`.
12651321
final List<Map<Name, ExecutableElementOrMember>> superImplemented;
12661322

1323+
/// Each item of this list maps names to their concrete implementations.
1324+
/// The first item of the list is the nominal superclass, next the nominal
1325+
/// superclass plus the first mixin, etc. So, for the class like
1326+
/// `class C extends S with M1, M2`, we get `[S, S&M1, S&M1&M2]`.
1327+
final List<Map<Name, ExecutableElement2>> superImplemented2;
1328+
12671329
/// The list of conflicts between superinterfaces - the nominal superclass,
12681330
/// mixins, and interfaces. Does not include conflicts with the declared
12691331
/// members of the class.
@@ -1277,11 +1339,14 @@ class Interface {
12771339
required this.map,
12781340
required this.declared,
12791341
required this.implemented,
1342+
required this.implemented2,
12801343
required this.noSuchMethodForwarders,
12811344
required this.overridden,
1345+
required this.overridden2,
12821346
required this.redeclared,
12831347
required this.redeclared2,
12841348
required this.superImplemented,
1349+
required this.superImplemented2,
12851350
required this.conflicts,
12861351
});
12871352

@@ -1291,6 +1356,19 @@ class Interface {
12911356
return declared.mapValue((element) => element.asElement2);
12921357
}
12931358

1359+
/// The map of names to the most specific signatures from the mixins,
1360+
/// superclasses, or interfaces.
1361+
Map<Name, ExecutableElement2>? get inheritedMap2 {
1362+
if (inheritedMap == null) {
1363+
return null;
1364+
}
1365+
var inheritedMap2 = <Name, ExecutableElement2>{};
1366+
for (var entry in inheritedMap!.entries) {
1367+
inheritedMap2[entry.key] = entry.value.asElement2;
1368+
}
1369+
return inheritedMap2;
1370+
}
1371+
12941372
/// The map of names to their signature in the interface.
12951373
@experimental
12961374
Map<Name, ExecutableElement2OrMember> get map2 {
@@ -1396,6 +1474,9 @@ class NotUniqueExtensionMemberConflict extends Conflict {
13961474
required super.name,
13971475
required this.candidates,
13981476
});
1477+
1478+
List<ExecutableElement2> get candidates2 =>
1479+
candidates.map((e) => e.asElement2).toList();
13991480
}
14001481

14011482
class _ExtensionTypeCandidates {

0 commit comments

Comments
 (0)