Fine. Handle duplicate top-level declarations in manifests.
Introduce first-class support for duplicate or cross-kind top-level name
conflicts in the fine-grained analyzer pipeline.
- Add `declaredConflicts` to `LibraryManifest` to record names that are
declared more than once (e.g., two classes) or across kinds (e.g., a
class and a top-level function). Conflicts are assigned a generated
`ManifestItemId` that is exported and used consistently.
- Ensure conflict handling covers related lookup names (e.g., getter/
setter pairs `foo` and `foo=`), removing them from per-kind declared
maps and placing a single entry in `declaredConflicts`.
- Update manifest building to detect conflicts deterministically:
- Stage variables, then getters/setters, then non-property members.
- Track `conflictingTopLevelElements` to skip invalid incremental
updates.
- Include `declaredConflicts` in serialization/deserialization and in
`exportMap` / `exportedIds`. Make `getDeclaredId` prefer conflicts.
- In `manifest_context`, resolve top-level IDs via `declaredConflicts`
before per-kind maps for stable identity.
- In requirements computation, skip conflicted names when producing
instances/interfaces, preventing inconsistent shapes and crashes.
- Make exported extensions resolution null-safe when duplicates exist.
- Extend result printing to display `declaredConflicts`.
- Bump `DATA_VERSION` to 580.
Why: Previously the analyzer assumed unique top-level names, which led
to crashes and inconsistent IDs when a library contained duplicates
(e.g., duplicate extension types, multiple classes named the same, or a
class/function collision). Representing conflicts explicitly yields
stable IDs, predictable exports, and reliable incremental linking and
diagnostics.
Bug: https://github.com/dart-lang/sdk/issues/61741
Change-Id: If153ce467f45156ee3918b5211b8e5e7b7f164ea
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/456485
Reviewed-by: Paul Berry <paulberry@google.com>
diff --git a/pkg/analyzer/lib/src/dart/analysis/driver.dart b/pkg/analyzer/lib/src/dart/analysis/driver.dart
index 8ab6655..8e380fa 100644
--- a/pkg/analyzer/lib/src/dart/analysis/driver.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/driver.dart
@@ -107,7 +107,7 @@
// TODO(scheglov): Clean up the list of implicitly analyzed files.
class AnalysisDriver {
/// The version of data format, should be incremented on every format change.
- static const int DATA_VERSION = 579;
+ static const int DATA_VERSION = 580;
/// The number of exception contexts allowed to write. Once this field is
/// zero, we stop writing any new exception contexts in this process.
diff --git a/pkg/analyzer/lib/src/fine/library_manifest.dart b/pkg/analyzer/lib/src/fine/library_manifest.dart
index b6bf4b7..e643051 100644
--- a/pkg/analyzer/lib/src/fine/library_manifest.dart
+++ b/pkg/analyzer/lib/src/fine/library_manifest.dart
@@ -41,6 +41,13 @@
/// The names that re-exported exclusively via deprecated exports.
final Set<LookupName> reExportDeprecatedOnly;
+ /// The names of duplicate or otherwise conflicting top-level declarations,
+ /// for example two classes with the same name, or a class and a top-level
+ /// function.
+ ///
+ /// These names are not in other `declaredXyz` maps.
+ final Map<LookupName, ManifestItemId> declaredConflicts;
+
final Map<LookupName, ClassItem> declaredClasses;
final Map<LookupName, EnumItem> declaredEnums;
final Map<LookupName, ExtensionItem> declaredExtensions;
@@ -88,6 +95,7 @@
required this.exportedLibraryUris,
required this.reExportMap,
required this.reExportDeprecatedOnly,
+ required this.declaredConflicts,
required this.declaredClasses,
required this.declaredEnums,
required this.declaredExtensions,
@@ -120,6 +128,7 @@
exportedLibraryUris: reader.readUriList(),
reExportMap: reader.readLookupNameToIdMap(),
reExportDeprecatedOnly: reader.readLookupNameSet(),
+ declaredConflicts: reader.readLookupNameToIdMap(),
declaredClasses: reader.readLookupNameMap(
readValue: () => ClassItem.read(reader),
),
@@ -160,6 +169,7 @@
Map<LookupName, ManifestItemId> get exportedIds {
return Map.fromEntries([
...reExportMap.entries,
+ ...declaredConflicts.entries,
...<Map<LookupName, ManifestItem>>[
declaredClasses,
declaredEnums,
@@ -180,7 +190,8 @@
/// Returns the ID of a declared top-level element, or `null` if there is no
/// such element.
ManifestItemId? getDeclaredId(LookupName name) {
- return declaredClasses[name]?.id ??
+ return declaredConflicts[name] ??
+ declaredClasses[name]?.id ??
declaredEnums[name]?.id ??
declaredExtensions[name]?.id ??
declaredExtensionTypes[name]?.id ??
@@ -213,6 +224,7 @@
writer.writeUriList(exportedLibraryUris);
reExportMap.write(writer);
reExportDeprecatedOnly.write(writer);
+ declaredConflicts.write(writer);
declaredClasses.write(writer);
declaredEnums.write(writer);
declaredExtensions.write(writer);
@@ -231,6 +243,7 @@
void _fillExportMap() {
exportMap.addAll(reExportMap);
+ exportMap.addAll(declaredConflicts);
void addDeclared<T extends ManifestItem>(Map<LookupName, T> items) {
for (var entry in items.entries) {
@@ -265,6 +278,11 @@
/// new IDs for them, etc.
final Map<Uri, LibraryManifest> inputManifests;
+ /// The top-level elements that are declared in this library, but conflict
+ /// with other top-level elements in the same library. For example, a class
+ /// and a top-level function with the same name.
+ final Set<Element> conflictingTopLevelElements = {};
+
/// Key: an element from [inputLibraries].
/// Value: the item from [inputManifests], or newly build.
///
@@ -454,8 +472,10 @@
var extensionLibraryManifest =
extensionElement.library.manifest!.instance;
var extensionItem =
- extensionLibraryManifest.declaredExtensions[extensionName]!;
- extensionIds.add(extensionItem.id);
+ extensionLibraryManifest.declaredExtensions[extensionName];
+ if (extensionItem != null) {
+ extensionIds.add(extensionItem.id);
+ }
}
manifest.exportedExtensions = ManifestItemIdList(
@@ -862,16 +882,20 @@
var encodingContext = EncodeContext(elementFactory: elementFactory);
for (var libraryElement in libraryElements) {
- var newClassItems = <LookupName, ClassItem>{};
- var newEnumItems = <LookupName, EnumItem>{};
- var newExtensionItems = <LookupName, ExtensionItem>{};
- var newExtensionTypeItems = <LookupName, ExtensionTypeItem>{};
- var newMixinItems = <LookupName, MixinItem>{};
- var newTypeAliasItems = <LookupName, TypeAliasItem>{};
+ var declaredNames = <LookupName>{};
+ var newConflicts = <LookupName, ManifestItemId>{};
+
+ var newTopLevelVariables = <LookupName, TopLevelVariableItem>{};
var newTopLevelGetters = <LookupName, GetterItem>{};
var newTopLevelSetters = <LookupName, SetterItem>{};
+
+ var newClasses = <LookupName, ClassItem>{};
+ var newEnums = <LookupName, EnumItem>{};
+ var newExtensions = <LookupName, ExtensionItem>{};
+ var newExtensionTypes = <LookupName, ExtensionTypeItem>{};
+ var newMixins = <LookupName, MixinItem>{};
+ var newTypeAliases = <LookupName, TypeAliasItem>{};
var newTopLevelFunctions = <LookupName, TopLevelFunctionItem>{};
- var newTopLevelVariables = <LookupName, TopLevelVariableItem>{};
var libraryMetadataItem = _getOrBuildElementItem(libraryElement, () {
return LibraryMetadataItem.encode(
@@ -881,83 +905,205 @@
);
});
- for (var element in libraryElement.children) {
+ void makeNameConflict(LookupName lookupName) {
+ var id = ManifestItemId.generate();
+ for (var relatedName in lookupName.relatedNames) {
+ newConflicts[relatedName] = id;
+ for (var lookupNameToItemMap in [
+ newClasses,
+ newEnums,
+ newExtensions,
+ newExtensionTypes,
+ newMixins,
+ newTypeAliases,
+ newTopLevelGetters,
+ newTopLevelSetters,
+ newTopLevelFunctions,
+ newTopLevelVariables,
+ ]) {
+ lookupNameToItemMap.remove(relatedName);
+ }
+ }
+ }
+
+ // First add top-level variables, and ignore conflicts.
+ // If there are conflicts, we will remove them in following loops.
+ for (var element in libraryElement.topLevelVariables) {
+ var lookupName = element.lookupName?.asLookupName;
+ if (lookupName != null) {
+ _addTopLevelVariable(
+ encodingContext: encodingContext,
+ newItems: newTopLevelVariables,
+ element: element,
+ lookupName: lookupName,
+ );
+ }
+ }
+
+ for (var element in libraryElement.getters) {
var lookupName = element.lookupName?.asLookupName;
if (lookupName == null) {
continue;
}
- switch (element) {
- case ClassElementImpl():
+ if (newConflicts.containsKey(lookupName)) {
+ conflictingTopLevelElements.add(element);
+ continue;
+ }
+ if (declaredNames.contains(lookupName)) {
+ conflictingTopLevelElements.add(element);
+ makeNameConflict(lookupName);
+ } else {
+ declaredNames.add(lookupName);
+ _addTopLevelGetter(
+ encodingContext: encodingContext,
+ newItems: newTopLevelGetters,
+ element: element,
+ lookupName: lookupName,
+ );
+ }
+ }
+
+ for (var element in libraryElement.setters) {
+ var lookupName = element.lookupName?.asLookupName;
+ if (lookupName == null) {
+ continue;
+ }
+ if (newConflicts.containsKey(lookupName)) {
+ conflictingTopLevelElements.add(element);
+ continue;
+ }
+ if (declaredNames.contains(lookupName)) {
+ conflictingTopLevelElements.add(element);
+ makeNameConflict(lookupName);
+ } else {
+ declaredNames.add(lookupName);
+ _addTopLevelSetter(
+ encodingContext: encodingContext,
+ newItems: newTopLevelSetters,
+ element: element,
+ lookupName: lookupName,
+ );
+ }
+ }
+
+ void addNonProperty({
+ required ElementImpl element,
+ required void Function(LookupName lookupName) addItem,
+ }) {
+ var lookupName = element.lookupName?.asLookupName;
+ if (lookupName == null) {
+ return;
+ }
+ if (newConflicts.containsKey(lookupName)) {
+ conflictingTopLevelElements.add(element);
+ return;
+ }
+ if (declaredNames.contains(lookupName) ||
+ declaredNames.contains(lookupName.methodToSetter)) {
+ conflictingTopLevelElements.add(element);
+ makeNameConflict(lookupName);
+ } else {
+ declaredNames.add(lookupName);
+ addItem(lookupName);
+ }
+ }
+
+ for (var element in libraryElement.classes) {
+ addNonProperty(
+ element: element,
+ addItem: (lookupName) {
_addClass(
encodingContext: encodingContext,
- newItems: newClassItems,
+ newItems: newClasses,
element: element,
lookupName: lookupName,
);
- case EnumElementImpl():
+ },
+ );
+ }
+
+ for (var element in libraryElement.enums) {
+ addNonProperty(
+ element: element,
+ addItem: (lookupName) {
_addEnum(
encodingContext: encodingContext,
- newItems: newEnumItems,
+ newItems: newEnums,
element: element,
lookupName: lookupName,
);
- case ExtensionElementImpl():
+ },
+ );
+ }
+
+ for (var element in libraryElement.extensions) {
+ addNonProperty(
+ element: element,
+ addItem: (lookupName) {
_addExtension(
encodingContext: encodingContext,
- newItems: newExtensionItems,
+ newItems: newExtensions,
element: element,
lookupName: lookupName,
);
- case ExtensionTypeElementImpl():
+ },
+ );
+ }
+
+ for (var element in libraryElement.extensionTypes) {
+ addNonProperty(
+ element: element,
+ addItem: (lookupName) {
_addExtensionType(
encodingContext: encodingContext,
- newItems: newExtensionTypeItems,
+ newItems: newExtensionTypes,
element: element,
lookupName: lookupName,
);
- case GetterElementImpl():
- _addTopLevelGetter(
- encodingContext: encodingContext,
- newItems: newTopLevelGetters,
- element: element,
- lookupName: lookupName,
- );
- case MixinElementImpl():
+ },
+ );
+ }
+
+ for (var element in libraryElement.mixins) {
+ addNonProperty(
+ element: element,
+ addItem: (lookupName) {
_addMixin(
encodingContext: encodingContext,
- newItems: newMixinItems,
+ newItems: newMixins,
element: element,
lookupName: lookupName,
);
- case SetterElementImpl():
- _addTopLevelSetter(
- encodingContext: encodingContext,
- newItems: newTopLevelSetters,
- element: element,
- lookupName: lookupName,
- );
- case TopLevelFunctionElementImpl():
+ },
+ );
+ }
+
+ for (var element in libraryElement.topLevelFunctions) {
+ addNonProperty(
+ element: element,
+ addItem: (lookupName) {
_addTopLevelFunction(
encodingContext: encodingContext,
newItems: newTopLevelFunctions,
element: element,
lookupName: lookupName,
);
- case TopLevelVariableElementImpl():
- _addTopLevelVariable(
- encodingContext: encodingContext,
- newItems: newTopLevelVariables,
- element: element,
- lookupName: lookupName,
- );
- case TypeAliasElementImpl():
+ },
+ );
+ }
+
+ for (var element in libraryElement.typeAliases) {
+ addNonProperty(
+ element: element,
+ addItem: (lookupName) {
_addTypeAlias(
encodingContext: encodingContext,
- newItems: newTypeAliasItems,
+ newItems: newTypeAliases,
element: element,
lookupName: lookupName,
);
- }
+ },
+ );
}
var newManifest = LibraryManifest(
@@ -973,12 +1119,13 @@
.toList(),
reExportMap: {},
reExportDeprecatedOnly: <LookupName>{},
- declaredClasses: newClassItems,
- declaredEnums: newEnumItems,
- declaredExtensions: newExtensionItems,
- declaredExtensionTypes: newExtensionTypeItems,
- declaredMixins: newMixinItems,
- declaredTypeAliases: newTypeAliasItems,
+ declaredConflicts: newConflicts,
+ declaredClasses: newClasses,
+ declaredEnums: newEnums,
+ declaredExtensions: newExtensions,
+ declaredExtensionTypes: newExtensionTypes,
+ declaredMixins: newMixins,
+ declaredTypeAliases: newTypeAliases,
declaredGetters: newTopLevelGetters,
declaredSetters: newTopLevelSetters,
declaredFunctions: newTopLevelFunctions,
@@ -1083,6 +1230,8 @@
addLookupName,
);
+ addMapOfIds(manifest.declaredConflicts);
+
void addDeclared(Map<LookupName, ManifestItem> map) {
var entries = sortedMapEntries(map);
builder.addMapEntryList(entries, (lookupName, item) {
@@ -1180,6 +1329,10 @@
return;
}
+ if (conflictingTopLevelElements.contains(element)) {
+ return;
+ }
+
// Must be created already.
var item = declaredItems[element] as InterfaceItem;
item.interface.beforeUpdating();
@@ -1375,6 +1528,7 @@
exportedLibraryUris: [],
reExportMap: {},
reExportDeprecatedOnly: <LookupName>{},
+ declaredConflicts: {},
declaredClasses: {},
declaredEnums: {},
declaredExtensions: {},
diff --git a/pkg/analyzer/lib/src/fine/manifest_context.dart b/pkg/analyzer/lib/src/fine/manifest_context.dart
index 5ed0a8f..0dabebe 100644
--- a/pkg/analyzer/lib/src/fine/manifest_context.dart
+++ b/pkg/analyzer/lib/src/fine/manifest_context.dart
@@ -372,6 +372,11 @@
// SAFETY: if we can reference the element, it has a name.
var topLevelName = topLevelElement.lookupName!.asLookupName;
+
+ if (manifest.declaredConflicts[topLevelName] case var id?) {
+ return id;
+ }
+
ManifestItem? topLevelItem;
switch (topLevelElement) {
case ClassElement():
diff --git a/pkg/analyzer/lib/src/fine/manifest_item.dart b/pkg/analyzer/lib/src/fine/manifest_item.dart
index e61b628..ffd95fd 100644
--- a/pkg/analyzer/lib/src/fine/manifest_item.dart
+++ b/pkg/analyzer/lib/src/fine/manifest_item.dart
@@ -786,16 +786,16 @@
inheritedConstructors.write(writer);
}
- void _makeNameConflict(LookupName lookupName2) {
+ void _makeNameConflict(LookupName lookupName) {
var id = ManifestItemId.generate();
- for (var lookupName in lookupName2.relatedNames) {
- declaredConflicts[lookupName] = id;
- declaredFields.remove(lookupName);
- declaredGetters.remove(lookupName);
- declaredSetters.remove(lookupName);
- declaredMethods.remove(lookupName);
- declaredConstructors.remove(lookupName);
- inheritedConstructors.remove(lookupName);
+ for (var relatedName in lookupName.relatedNames) {
+ declaredConflicts[relatedName] = id;
+ declaredFields.remove(relatedName);
+ declaredGetters.remove(relatedName);
+ declaredSetters.remove(relatedName);
+ declaredMethods.remove(relatedName);
+ declaredConstructors.remove(relatedName);
+ inheritedConstructors.remove(relatedName);
}
}
}
diff --git a/pkg/analyzer/lib/src/fine/requirements.dart b/pkg/analyzer/lib/src/fine/requirements.dart
index cd03e1b..e9c2408 100644
--- a/pkg/analyzer/lib/src/fine/requirements.dart
+++ b/pkg/analyzer/lib/src/fine/requirements.dart
@@ -2649,6 +2649,11 @@
return null;
}
+ // Skip conflicts.
+ if (manifest.declaredConflicts.containsKey(instanceName)) {
+ return null;
+ }
+
var libraryRequirements = _getLibraryRequirements(libraryElement);
var instancesMap = libraryRequirements.instances;
var instanceItem =
@@ -2692,6 +2697,11 @@
return null;
}
+ // Skip conflicts.
+ if (manifest.declaredConflicts.containsKey(interfaceName)) {
+ return null;
+ }
+
var libraryRequirements = _getLibraryRequirements(libraryElement);
var interfacesMap = libraryRequirements.interfaces;
var interfaceItem =
diff --git a/pkg/analyzer/test/src/dart/analysis/driver_test.dart b/pkg/analyzer/test/src/dart/analysis/driver_test.dart
index c4883f9..d2f2931 100644
--- a/pkg/analyzer/test/src/dart/analysis/driver_test.dart
+++ b/pkg/analyzer/test/src/dart/analysis/driver_test.dart
@@ -16330,6 +16330,619 @@
);
}
+ test_dependency_class_it_conflict_fix() async {
+ configuration
+ ..withGetErrorsEvents = false
+ ..withStreamResolvedUnitResults = false;
+
+ await _runChangeScenarioTA(
+ initialA: r'''
+class A {}
+class A {}
+''',
+ testCode: r'''
+import 'a.dart';
+A foo() {}
+''',
+ operation: _FineOperationTestFileGetErrors(),
+ expectedInitialEvents: r'''
+[status] working
+[operation] linkLibraryCycle SDK
+[operation] linkLibraryCycle
+ package:test/a.dart
+ hashForRequirements: #H0
+ declaredConflicts
+ A: #M0
+ A=: #M0
+ exportMapId: #M1
+ exportMap
+ A: #M0
+ A=: #M0
+ requirements
+[operation] linkLibraryCycle
+ package:test/test.dart
+ hashForRequirements: #H1
+ declaredFunctions
+ foo: #M2
+ exportMapId: #M3
+ exportMap
+ foo: #M2
+ requirements
+ libraries
+ package:test/a.dart
+ exportMapId: #M1
+ exportMap
+ A: #M0
+ A=: #M0
+ reExportDeprecatedOnly
+ A: false
+ A=: false
+[operation] analyzeFile
+ file: /home/test/lib/test.dart
+ library: /home/test/lib/test.dart
+[operation] analyzedLibrary
+ file: /home/test/lib/test.dart
+ requirements
+ libraries
+ package:test/a.dart
+ libraryMetadataId: #M4
+ exportMapId: #M1
+ exportMap
+ A: #M0
+ A=: #M0
+ reExportDeprecatedOnly
+ A: false
+ A=: false
+[status] idle
+''',
+ updatedA: r'''
+class A {}
+''',
+ expectedUpdatedEvents: r'''
+[status] working
+[operation] linkLibraryCycle
+ package:test/a.dart
+ hashForRequirements: #H2
+ declaredClasses
+ A: #M5
+ interface: #M6
+ exportMapId: #M7
+ exportMap
+ A: #M5
+ requirements
+[operation] checkLinkedBundleRequirements
+ package:test/test.dart
+ topLevelIdMismatch
+ libraryUri: package:test/a.dart
+ name: A
+ expectedId: #M0
+ actualId: #M5
+[operation] linkLibraryCycle
+ package:test/test.dart
+ hashForRequirements: #H3
+ declaredFunctions
+ foo: #M8
+ exportMapId: #M9
+ exportMap
+ foo: #M8
+ requirements
+ libraries
+ package:test/a.dart
+ exportMapId: #M7
+ exportMap
+ A: #M5
+ A=: <null>
+ reExportDeprecatedOnly
+ A: false
+[operation] checkLibraryDiagnosticsRequirements
+ library: /home/test/lib/test.dart
+ topLevelIdMismatch
+ libraryUri: package:test/a.dart
+ name: A
+ expectedId: #M0
+ actualId: #M5
+[operation] analyzeFile
+ file: /home/test/lib/test.dart
+ library: /home/test/lib/test.dart
+[operation] analyzedLibrary
+ file: /home/test/lib/test.dart
+ requirements
+ libraries
+ package:test/a.dart
+ libraryMetadataId: #M4
+ exportMapId: #M7
+ exportMap
+ A: #M5
+ A=: <null>
+ reExportDeprecatedOnly
+ A: false
+[status] idle
+''',
+ );
+ }
+
+ test_dependency_class_it_conflict_introduce() async {
+ configuration
+ ..withGetErrorsEvents = false
+ ..withStreamResolvedUnitResults = false;
+
+ await _runChangeScenarioTA(
+ initialA: r'''
+class A {}
+''',
+ testCode: r'''
+import 'a.dart';
+A foo() {}
+''',
+ operation: _FineOperationTestFileGetErrors(),
+ expectedInitialEvents: r'''
+[status] working
+[operation] linkLibraryCycle SDK
+[operation] linkLibraryCycle
+ package:test/a.dart
+ hashForRequirements: #H0
+ declaredClasses
+ A: #M0
+ interface: #M1
+ exportMapId: #M2
+ exportMap
+ A: #M0
+ requirements
+[operation] linkLibraryCycle
+ package:test/test.dart
+ hashForRequirements: #H1
+ declaredFunctions
+ foo: #M3
+ exportMapId: #M4
+ exportMap
+ foo: #M3
+ requirements
+ libraries
+ package:test/a.dart
+ exportMapId: #M2
+ exportMap
+ A: #M0
+ A=: <null>
+ reExportDeprecatedOnly
+ A: false
+[operation] analyzeFile
+ file: /home/test/lib/test.dart
+ library: /home/test/lib/test.dart
+[operation] analyzedLibrary
+ file: /home/test/lib/test.dart
+ requirements
+ libraries
+ package:test/a.dart
+ libraryMetadataId: #M5
+ exportMapId: #M2
+ exportMap
+ A: #M0
+ A=: <null>
+ reExportDeprecatedOnly
+ A: false
+[status] idle
+''',
+ updatedA: r'''
+class A {}
+class A {}
+''',
+ expectedUpdatedEvents: r'''
+[status] working
+[operation] linkLibraryCycle
+ package:test/a.dart
+ hashForRequirements: #H2
+ declaredConflicts
+ A: #M6
+ A=: #M6
+ exportMapId: #M7
+ exportMap
+ A: #M6
+ A=: #M6
+ requirements
+[operation] checkLinkedBundleRequirements
+ package:test/test.dart
+ topLevelIdMismatch
+ libraryUri: package:test/a.dart
+ name: A
+ expectedId: #M0
+ actualId: #M6
+[operation] linkLibraryCycle
+ package:test/test.dart
+ hashForRequirements: #H3
+ declaredFunctions
+ foo: #M8
+ exportMapId: #M9
+ exportMap
+ foo: #M8
+ requirements
+ libraries
+ package:test/a.dart
+ exportMapId: #M7
+ exportMap
+ A: #M6
+ A=: #M6
+ reExportDeprecatedOnly
+ A: false
+ A=: false
+[operation] checkLibraryDiagnosticsRequirements
+ library: /home/test/lib/test.dart
+ topLevelIdMismatch
+ libraryUri: package:test/a.dart
+ name: A
+ expectedId: #M0
+ actualId: #M6
+[operation] analyzeFile
+ file: /home/test/lib/test.dart
+ library: /home/test/lib/test.dart
+[operation] analyzedLibrary
+ file: /home/test/lib/test.dart
+ requirements
+ libraries
+ package:test/a.dart
+ libraryMetadataId: #M5
+ exportMapId: #M7
+ exportMap
+ A: #M6
+ A=: #M6
+ reExportDeprecatedOnly
+ A: false
+ A=: false
+[status] idle
+''',
+ );
+ }
+
+ test_dependency_class_it_conflict_keep() async {
+ configuration
+ ..withGetErrorsEvents = false
+ ..withStreamResolvedUnitResults = false;
+
+ await _runChangeScenarioTA(
+ initialA: r'''
+class A {}
+class A {}
+''',
+ testCode: r'''
+import 'a.dart';
+A foo() {}
+''',
+ operation: _FineOperationTestFileGetErrors(),
+ expectedInitialEvents: r'''
+[status] working
+[operation] linkLibraryCycle SDK
+[operation] linkLibraryCycle
+ package:test/a.dart
+ hashForRequirements: #H0
+ declaredConflicts
+ A: #M0
+ A=: #M0
+ exportMapId: #M1
+ exportMap
+ A: #M0
+ A=: #M0
+ requirements
+[operation] linkLibraryCycle
+ package:test/test.dart
+ hashForRequirements: #H1
+ declaredFunctions
+ foo: #M2
+ exportMapId: #M3
+ exportMap
+ foo: #M2
+ requirements
+ libraries
+ package:test/a.dart
+ exportMapId: #M1
+ exportMap
+ A: #M0
+ A=: #M0
+ reExportDeprecatedOnly
+ A: false
+ A=: false
+[operation] analyzeFile
+ file: /home/test/lib/test.dart
+ library: /home/test/lib/test.dart
+[operation] analyzedLibrary
+ file: /home/test/lib/test.dart
+ requirements
+ libraries
+ package:test/a.dart
+ libraryMetadataId: #M4
+ exportMapId: #M1
+ exportMap
+ A: #M0
+ A=: #M0
+ reExportDeprecatedOnly
+ A: false
+ A=: false
+[status] idle
+''',
+ updatedA: r'''
+class A {}
+class A {}
+class B {}
+''',
+ expectedUpdatedEvents: r'''
+[status] working
+[operation] linkLibraryCycle
+ package:test/a.dart
+ hashForRequirements: #H2
+ declaredConflicts
+ A: #M5
+ A=: #M5
+ declaredClasses
+ B: #M6
+ interface: #M7
+ exportMapId: #M8
+ exportMap
+ A: #M5
+ A=: #M5
+ B: #M6
+ requirements
+[operation] checkLinkedBundleRequirements
+ package:test/test.dart
+ topLevelIdMismatch
+ libraryUri: package:test/a.dart
+ name: A
+ expectedId: #M0
+ actualId: #M5
+[operation] linkLibraryCycle
+ package:test/test.dart
+ hashForRequirements: #H3
+ declaredFunctions
+ foo: #M9
+ exportMapId: #M10
+ exportMap
+ foo: #M9
+ requirements
+ libraries
+ package:test/a.dart
+ exportMapId: #M8
+ exportMap
+ A: #M5
+ A=: #M5
+ reExportDeprecatedOnly
+ A: false
+ A=: false
+[operation] checkLibraryDiagnosticsRequirements
+ library: /home/test/lib/test.dart
+ topLevelIdMismatch
+ libraryUri: package:test/a.dart
+ name: A
+ expectedId: #M0
+ actualId: #M5
+[operation] analyzeFile
+ file: /home/test/lib/test.dart
+ library: /home/test/lib/test.dart
+[operation] analyzedLibrary
+ file: /home/test/lib/test.dart
+ requirements
+ libraries
+ package:test/a.dart
+ libraryMetadataId: #M4
+ exportMapId: #M8
+ exportMap
+ A: #M5
+ A=: #M5
+ reExportDeprecatedOnly
+ A: false
+ A=: false
+[status] idle
+''',
+ );
+ }
+
+ test_dependency_class_it_extension_fix() async {
+ configuration
+ ..withGetErrorsEvents = false
+ ..withStreamResolvedUnitResults = false;
+
+ await _runChangeScenarioTA(
+ initialA: r'''
+extension E on int {
+ void foo() {}
+}
+extension E on int {
+ void foo() {}
+}
+''',
+ testCode: r'''
+import 'a.dart';
+void f() {
+ 0.foo();
+}
+''',
+ operation: _FineOperationTestFileGetErrors(),
+ expectedInitialEvents: r'''
+[status] working
+[operation] linkLibraryCycle SDK
+[operation] linkLibraryCycle
+ package:test/a.dart
+ hashForRequirements: #H0
+ declaredConflicts
+ E: #M0
+ E=: #M0
+ exportMapId: #M1
+ exportMap
+ E: #M0
+ E=: #M0
+ requirements
+[operation] linkLibraryCycle
+ package:test/test.dart
+ hashForRequirements: #H1
+ declaredFunctions
+ f: #M2
+ exportMapId: #M3
+ exportMap
+ f: #M2
+ requirements
+[operation] analyzeFile
+ file: /home/test/lib/test.dart
+ library: /home/test/lib/test.dart
+[operation] analyzedLibrary
+ file: /home/test/lib/test.dart
+ requirements
+ libraries
+ package:test/a.dart
+ libraryMetadataId: #M4
+ exportMapId: #M1
+ exportedExtensions: []
+[status] idle
+''',
+ updatedA: r'''
+extension E on int {
+ void foo() {}
+}
+''',
+ expectedUpdatedEvents: r'''
+[status] working
+[operation] linkLibraryCycle
+ package:test/a.dart
+ hashForRequirements: #H2
+ declaredExtensions
+ E: #M5
+ declaredMethods
+ foo: #M6
+ exportMapId: #M7
+ exportMap
+ E: #M5
+ exportedExtensions: #M5
+ requirements
+[operation] reuseLinkedBundle
+ package:test/test.dart
+[operation] checkLibraryDiagnosticsRequirements
+ library: /home/test/lib/test.dart
+ exportedExtensionsMismatch
+ libraryUri: package:test/a.dart
+ expectedIds: []
+ actualIds: #M5
+[operation] analyzeFile
+ file: /home/test/lib/test.dart
+ library: /home/test/lib/test.dart
+[operation] analyzedLibrary
+ file: /home/test/lib/test.dart
+ requirements
+ libraries
+ package:test/a.dart
+ libraryMetadataId: #M4
+ exportMapId: #M7
+ instances
+ E
+ requestedDeclaredFields
+ foo: <null>
+ requestedDeclaredMethods
+ foo: #M6
+ exportedExtensions: #M5
+[status] idle
+''',
+ );
+ }
+
+ test_dependency_class_it_extension_introduce() async {
+ configuration
+ ..withGetErrorsEvents = false
+ ..withStreamResolvedUnitResults = false;
+
+ await _runChangeScenarioTA(
+ initialA: r'''
+extension E on int {
+ void foo() {}
+}
+''',
+ testCode: r'''
+import 'a.dart';
+void f() {
+ 0.foo();
+}
+''',
+ operation: _FineOperationTestFileGetErrors(),
+ expectedInitialEvents: r'''
+[status] working
+[operation] linkLibraryCycle SDK
+[operation] linkLibraryCycle
+ package:test/a.dart
+ hashForRequirements: #H0
+ declaredExtensions
+ E: #M0
+ declaredMethods
+ foo: #M1
+ exportMapId: #M2
+ exportMap
+ E: #M0
+ exportedExtensions: #M0
+ requirements
+[operation] linkLibraryCycle
+ package:test/test.dart
+ hashForRequirements: #H1
+ declaredFunctions
+ f: #M3
+ exportMapId: #M4
+ exportMap
+ f: #M3
+ requirements
+[operation] analyzeFile
+ file: /home/test/lib/test.dart
+ library: /home/test/lib/test.dart
+[operation] analyzedLibrary
+ file: /home/test/lib/test.dart
+ requirements
+ libraries
+ package:test/a.dart
+ libraryMetadataId: #M5
+ exportMapId: #M2
+ instances
+ E
+ requestedDeclaredFields
+ foo: <null>
+ requestedDeclaredMethods
+ foo: #M1
+ exportedExtensions: #M0
+[status] idle
+''',
+ updatedA: r'''
+extension E on int {
+ void foo() {}
+}
+extension E on int {
+ void foo() {}
+}
+''',
+ expectedUpdatedEvents: r'''
+[status] working
+[operation] linkLibraryCycle
+ package:test/a.dart
+ hashForRequirements: #H2
+ declaredConflicts
+ E: #M6
+ E=: #M6
+ exportMapId: #M7
+ exportMap
+ E: #M6
+ E=: #M6
+ requirements
+[operation] reuseLinkedBundle
+ package:test/test.dart
+[operation] checkLibraryDiagnosticsRequirements
+ library: /home/test/lib/test.dart
+ topLevelNotInstance
+ libraryUri: package:test/a.dart
+ name: E
+[operation] analyzeFile
+ file: /home/test/lib/test.dart
+ library: /home/test/lib/test.dart
+[operation] analyzedLibrary
+ file: /home/test/lib/test.dart
+ requirements
+ libraries
+ package:test/a.dart
+ libraryMetadataId: #M5
+ exportMapId: #M7
+ exportedExtensions: []
+[status] idle
+''',
+ );
+ }
+
test_dependency_class_it_remove() async {
await _runChangeScenarioTA(
initialA: r'''
@@ -80102,6 +80715,59 @@
);
}
+ test_manifest_extensionType_addConflict() async {
+ // See https://github.com/dart-lang/sdk/issues/61741
+ await _runLibraryManifestScenario(
+ initialCode: r'''
+extension type E(List<int> it) {
+ int get foo => 0;
+}
+''',
+ expectedInitialEvents: r'''
+[operation] linkLibraryCycle SDK
+[operation] linkLibraryCycle
+ package:test/test.dart
+ hashForRequirements: #H0
+ declaredExtensionTypes
+ E: #M0
+ declaredFields
+ foo: #M1
+ it: #M2
+ declaredGetters
+ foo: #M3
+ it: #M4
+ interface: #M5
+ map
+ foo: #M3
+ it: #M4
+ implemented
+ foo: #M3
+ it: #M4
+ exportMapId: #M6
+ exportMap
+ E: #M0
+''',
+ updatedCode: r'''
+extension type E(List<int> it) {
+ int get foo => 0;
+}
+extension type E(List<int> it) {}
+''',
+ expectedUpdatedEvents: r'''
+[operation] linkLibraryCycle
+ package:test/test.dart
+ hashForRequirements: #H1
+ declaredConflicts
+ E: #M7
+ E=: #M7
+ exportMapId: #M8
+ exportMap
+ E: #M7
+ E=: #M7
+''',
+ );
+ }
+
test_manifest_extensionType_constructor_idChangesWithContainer() async {
await _runLibraryManifestScenario(
initialCode: r'''
@@ -90693,6 +91359,997 @@
);
}
+ test_manifest_topConflict_class_class_class() async {
+ await _runLibraryManifestScenario(
+ initialCode: r'''
+class A {
+ void foo() {}
+}
+class A {
+ void foo() {}
+}
+class A {
+ void foo() {}
+}
+''',
+ expectedInitialEvents: r'''
+[operation] linkLibraryCycle SDK
+[operation] linkLibraryCycle
+ package:test/test.dart
+ hashForRequirements: #H0
+ declaredConflicts
+ A: #M0
+ A=: #M0
+ exportMapId: #M1
+ exportMap
+ A: #M0
+ A=: #M0
+''',
+ updatedCode: r'''
+class A {
+ void foo() {}
+}
+class A {
+ void foo() {}
+}
+class A {
+ void foo() {}
+}
+class B {}
+''',
+ expectedUpdatedEvents: r'''
+[operation] linkLibraryCycle
+ package:test/test.dart
+ hashForRequirements: #H1
+ declaredConflicts
+ A: #M2
+ A=: #M2
+ declaredClasses
+ B: #M3
+ interface: #M4
+ exportMapId: #M5
+ exportMap
+ A: #M2
+ A=: #M2
+ B: #M3
+''',
+ );
+ }
+
+ test_manifest_topConflict_class_topFunction() async {
+ await _runLibraryManifestScenario(
+ initialCode: r'''
+class A {}
+void A() {}
+''',
+ expectedInitialEvents: r'''
+[operation] linkLibraryCycle SDK
+[operation] linkLibraryCycle
+ package:test/test.dart
+ hashForRequirements: #H0
+ declaredConflicts
+ A: #M0
+ A=: #M0
+ exportMapId: #M1
+ exportMap
+ A: #M0
+ A=: #M0
+''',
+ updatedCode: r'''
+class A {}
+void A() {}
+class B {}
+''',
+ expectedUpdatedEvents: r'''
+[operation] linkLibraryCycle
+ package:test/test.dart
+ hashForRequirements: #H1
+ declaredConflicts
+ A: #M2
+ A=: #M2
+ declaredClasses
+ B: #M3
+ interface: #M4
+ exportMapId: #M5
+ exportMap
+ A: #M2
+ A=: #M2
+ B: #M3
+''',
+ );
+ }
+
+ test_manifest_topConflict_enum_enum_enum() async {
+ await _runLibraryManifestScenario(
+ initialCode: r'''
+enum A {v}
+enum A {v}
+enum A {v}
+''',
+ expectedInitialEvents: r'''
+[operation] linkLibraryCycle SDK
+[operation] linkLibraryCycle
+ package:test/test.dart
+ hashForRequirements: #H0
+ declaredConflicts
+ A: #M0
+ A=: #M0
+ exportMapId: #M1
+ exportMap
+ A: #M0
+ A=: #M0
+''',
+ updatedCode: r'''
+enum A {v}
+enum A {v}
+enum A {v}
+class B {}
+''',
+ expectedUpdatedEvents: r'''
+[operation] linkLibraryCycle
+ package:test/test.dart
+ hashForRequirements: #H1
+ declaredConflicts
+ A: #M2
+ A=: #M2
+ declaredClasses
+ B: #M3
+ interface: #M4
+ exportMapId: #M5
+ exportMap
+ A: #M2
+ A=: #M2
+ B: #M3
+''',
+ );
+ }
+
+ test_manifest_topConflict_extension_extension_extension() async {
+ await _runLibraryManifestScenario(
+ initialCode: r'''
+extension A on int {
+ void foo() {}
+}
+extension A on int {
+ void foo() {}
+}
+extension A on int {
+ void foo() {}
+}
+''',
+ expectedInitialEvents: r'''
+[operation] linkLibraryCycle SDK
+[operation] linkLibraryCycle
+ package:test/test.dart
+ hashForRequirements: #H0
+ declaredConflicts
+ A: #M0
+ A=: #M0
+ exportMapId: #M1
+ exportMap
+ A: #M0
+ A=: #M0
+''',
+ updatedCode: r'''
+extension A on int {
+ void foo() {}
+}
+extension A on int {
+ void foo() {}
+}
+extension A on int {
+ void foo() {}
+}
+class B {}
+''',
+ expectedUpdatedEvents: r'''
+[operation] linkLibraryCycle
+ package:test/test.dart
+ hashForRequirements: #H1
+ declaredConflicts
+ A: #M2
+ A=: #M2
+ declaredClasses
+ B: #M3
+ interface: #M4
+ exportMapId: #M5
+ exportMap
+ A: #M2
+ A=: #M2
+ B: #M3
+''',
+ );
+ }
+
+ test_manifest_topConflict_extensionType_extensionType_extensionType() async {
+ await _runLibraryManifestScenario(
+ initialCode: r'''
+extension type A(int it) {
+ void foo() {}
+}
+extension type A(int it) {
+ void foo() {}
+}
+extension type A(int it) {
+ void foo() {}
+}
+''',
+ expectedInitialEvents: r'''
+[operation] linkLibraryCycle SDK
+[operation] linkLibraryCycle
+ package:test/test.dart
+ hashForRequirements: #H0
+ declaredConflicts
+ A: #M0
+ A=: #M0
+ exportMapId: #M1
+ exportMap
+ A: #M0
+ A=: #M0
+''',
+ updatedCode: r'''
+extension type A(int it) {
+ void foo() {}
+}
+extension type A(int it) {
+ void foo() {}
+}
+extension type A(int it) {
+ void foo() {}
+}
+class B {}
+''',
+ expectedUpdatedEvents: r'''
+[operation] linkLibraryCycle
+ package:test/test.dart
+ hashForRequirements: #H1
+ declaredConflicts
+ A: #M2
+ A=: #M2
+ declaredClasses
+ B: #M3
+ interface: #M4
+ exportMapId: #M5
+ exportMap
+ A: #M2
+ A=: #M2
+ B: #M3
+''',
+ );
+ }
+
+ test_manifest_topConflict_getter_class() async {
+ await _runLibraryManifestScenario(
+ initialCode: r'''
+int get A => 0;
+class A {}
+''',
+ expectedInitialEvents: r'''
+[operation] linkLibraryCycle SDK
+[operation] linkLibraryCycle
+ package:test/test.dart
+ hashForRequirements: #H0
+ declaredConflicts
+ A: #M0
+ A=: #M0
+ exportMapId: #M1
+ exportMap
+ A: #M0
+ A=: #M0
+''',
+ updatedCode: r'''
+int get A => 0;
+class A {}
+class B {}
+''',
+ expectedUpdatedEvents: r'''
+[operation] linkLibraryCycle
+ package:test/test.dart
+ hashForRequirements: #H1
+ declaredConflicts
+ A: #M2
+ A=: #M2
+ declaredClasses
+ B: #M3
+ interface: #M4
+ exportMapId: #M5
+ exportMap
+ A: #M2
+ A=: #M2
+ B: #M3
+''',
+ );
+ }
+
+ test_manifest_topConflict_getter_getter_getter() async {
+ await _runLibraryManifestScenario(
+ initialCode: r'''
+int get foo => 0;
+int get foo => 0;
+int get foo => 0;
+''',
+ expectedInitialEvents: r'''
+[operation] linkLibraryCycle SDK
+[operation] linkLibraryCycle
+ package:test/test.dart
+ hashForRequirements: #H0
+ declaredConflicts
+ foo: #M0
+ foo=: #M0
+ exportMapId: #M1
+ exportMap
+ foo: #M0
+ foo=: #M0
+''',
+ updatedCode: r'''
+int get foo => 0;
+int get foo => 0;
+int get foo => 0;
+class B {}
+''',
+ expectedUpdatedEvents: r'''
+[operation] linkLibraryCycle
+ package:test/test.dart
+ hashForRequirements: #H1
+ declaredConflicts
+ foo: #M2
+ foo=: #M2
+ declaredClasses
+ B: #M3
+ interface: #M4
+ exportMapId: #M5
+ exportMap
+ B: #M3
+ foo: #M2
+ foo=: #M2
+''',
+ );
+ }
+
+ test_manifest_topConflict_getter_getter_setter() async {
+ await _runLibraryManifestScenario(
+ initialCode: r'''
+int get foo => 0;
+int get foo => 0;
+set foo(int _) {}
+''',
+ expectedInitialEvents: r'''
+[operation] linkLibraryCycle SDK
+[operation] linkLibraryCycle
+ package:test/test.dart
+ hashForRequirements: #H0
+ declaredConflicts
+ foo: #M0
+ foo=: #M0
+ exportMapId: #M1
+ exportMap
+ foo: #M0
+ foo=: #M0
+''',
+ updatedCode: r'''
+int get foo => 0;
+int get foo => 0;
+set foo(int _) {}
+class B {}
+''',
+ expectedUpdatedEvents: r'''
+[operation] linkLibraryCycle
+ package:test/test.dart
+ hashForRequirements: #H1
+ declaredConflicts
+ foo: #M2
+ foo=: #M2
+ declaredClasses
+ B: #M3
+ interface: #M4
+ exportMapId: #M5
+ exportMap
+ B: #M3
+ foo: #M2
+ foo=: #M2
+''',
+ );
+ }
+
+ test_manifest_topConflict_getter_setter() async {
+ await _runLibraryManifestScenario(
+ initialCode: r'''
+int get foo => 0;
+set foo(int _) {}
+''',
+ expectedInitialEvents: r'''
+[operation] linkLibraryCycle SDK
+[operation] linkLibraryCycle
+ package:test/test.dart
+ hashForRequirements: #H0
+ declaredGetters
+ foo: #M0
+ declaredSetters
+ foo=: #M1
+ declaredVariables
+ foo: #M2
+ exportMapId: #M3
+ exportMap
+ foo: #M0
+ foo=: #M1
+''',
+ updatedCode: r'''
+int get foo => 0;
+set foo(int _) {}
+class B {}
+''',
+ expectedUpdatedEvents: r'''
+[operation] linkLibraryCycle
+ package:test/test.dart
+ hashForRequirements: #H1
+ declaredClasses
+ B: #M4
+ interface: #M5
+ declaredGetters
+ foo: #M0
+ declaredSetters
+ foo=: #M1
+ declaredVariables
+ foo: #M2
+ exportMapId: #M6
+ exportMap
+ B: #M4
+ foo: #M0
+ foo=: #M1
+''',
+ );
+ }
+
+ test_manifest_topConflict_getter_setter_setter() async {
+ await _runLibraryManifestScenario(
+ initialCode: r'''
+int get foo => 0;
+set foo(int _) {}
+set foo(int _) {}
+''',
+ expectedInitialEvents: r'''
+[operation] linkLibraryCycle SDK
+[operation] linkLibraryCycle
+ package:test/test.dart
+ hashForRequirements: #H0
+ declaredConflicts
+ foo: #M0
+ foo=: #M0
+ exportMapId: #M1
+ exportMap
+ foo: #M0
+ foo=: #M0
+''',
+ updatedCode: r'''
+int get foo => 0;
+set foo(int _) {}
+set foo(int _) {}
+class B {}
+''',
+ expectedUpdatedEvents: r'''
+[operation] linkLibraryCycle
+ package:test/test.dart
+ hashForRequirements: #H1
+ declaredConflicts
+ foo: #M2
+ foo=: #M2
+ declaredClasses
+ B: #M3
+ interface: #M4
+ exportMapId: #M5
+ exportMap
+ B: #M3
+ foo: #M2
+ foo=: #M2
+''',
+ );
+ }
+
+ test_manifest_topConflict_mixin_mixin_mixin() async {
+ await _runLibraryManifestScenario(
+ initialCode: r'''
+mixin A {
+ void foo() {}
+}
+mixin A {
+ void foo() {}
+}
+mixin A {
+ void foo() {}
+}
+''',
+ expectedInitialEvents: r'''
+[operation] linkLibraryCycle SDK
+[operation] linkLibraryCycle
+ package:test/test.dart
+ hashForRequirements: #H0
+ declaredConflicts
+ A: #M0
+ A=: #M0
+ exportMapId: #M1
+ exportMap
+ A: #M0
+ A=: #M0
+''',
+ updatedCode: r'''
+mixin A {
+ void foo() {}
+}
+mixin A {
+ void foo() {}
+}
+mixin A {
+ void foo() {}
+}
+class B {}
+''',
+ expectedUpdatedEvents: r'''
+[operation] linkLibraryCycle
+ package:test/test.dart
+ hashForRequirements: #H1
+ declaredConflicts
+ A: #M2
+ A=: #M2
+ declaredClasses
+ B: #M3
+ interface: #M4
+ exportMapId: #M5
+ exportMap
+ A: #M2
+ A=: #M2
+ B: #M3
+''',
+ );
+ }
+
+ test_manifest_topConflict_setter_getter() async {
+ await _runLibraryManifestScenario(
+ initialCode: r'''
+set foo(int _) {}
+int get foo => 0;
+''',
+ expectedInitialEvents: r'''
+[operation] linkLibraryCycle SDK
+[operation] linkLibraryCycle
+ package:test/test.dart
+ hashForRequirements: #H0
+ declaredGetters
+ foo: #M0
+ declaredSetters
+ foo=: #M1
+ declaredVariables
+ foo: #M2
+ exportMapId: #M3
+ exportMap
+ foo: #M0
+ foo=: #M1
+''',
+ updatedCode: r'''
+set foo(int _) {}
+int get foo => 0;
+class B {}
+''',
+ expectedUpdatedEvents: r'''
+[operation] linkLibraryCycle
+ package:test/test.dart
+ hashForRequirements: #H1
+ declaredClasses
+ B: #M4
+ interface: #M5
+ declaredGetters
+ foo: #M0
+ declaredSetters
+ foo=: #M1
+ declaredVariables
+ foo: #M2
+ exportMapId: #M6
+ exportMap
+ B: #M4
+ foo: #M0
+ foo=: #M1
+''',
+ );
+ }
+
+ test_manifest_topConflict_setter_setter_setter() async {
+ await _runLibraryManifestScenario(
+ initialCode: r'''
+set foo(int _) {}
+set foo(int _) {}
+set foo(int _) {}
+''',
+ expectedInitialEvents: r'''
+[operation] linkLibraryCycle SDK
+[operation] linkLibraryCycle
+ package:test/test.dart
+ hashForRequirements: #H0
+ declaredConflicts
+ foo: #M0
+ foo=: #M0
+ exportMapId: #M1
+ exportMap
+ foo: #M0
+ foo=: #M0
+''',
+ updatedCode: r'''
+set foo(int _) {}
+set foo(int _) {}
+set foo(int _) {}
+class B {}
+''',
+ expectedUpdatedEvents: r'''
+[operation] linkLibraryCycle
+ package:test/test.dart
+ hashForRequirements: #H1
+ declaredConflicts
+ foo: #M2
+ foo=: #M2
+ declaredClasses
+ B: #M3
+ interface: #M4
+ exportMapId: #M5
+ exportMap
+ B: #M3
+ foo: #M2
+ foo=: #M2
+''',
+ );
+ }
+
+ test_manifest_topConflict_topFunction3_to1() async {
+ await _runLibraryManifestScenario(
+ initialCode: r'''
+void foo() {}
+void foo() {}
+void foo() {}
+''',
+ expectedInitialEvents: r'''
+[operation] linkLibraryCycle SDK
+[operation] linkLibraryCycle
+ package:test/test.dart
+ hashForRequirements: #H0
+ declaredConflicts
+ foo: #M0
+ foo=: #M0
+ exportMapId: #M1
+ exportMap
+ foo: #M0
+ foo=: #M0
+''',
+ updatedCode: r'''
+void foo() {}
+class B {}
+''',
+ expectedUpdatedEvents: r'''
+[operation] linkLibraryCycle
+ package:test/test.dart
+ hashForRequirements: #H1
+ declaredClasses
+ B: #M2
+ interface: #M3
+ declaredFunctions
+ foo: #M4
+ exportMapId: #M5
+ exportMap
+ B: #M2
+ foo: #M4
+''',
+ );
+ }
+
+ test_manifest_topConflict_topFunction_topFunction_topFunction() async {
+ await _runLibraryManifestScenario(
+ initialCode: r'''
+void foo() {}
+void foo() {}
+void foo() {}
+''',
+ expectedInitialEvents: r'''
+[operation] linkLibraryCycle SDK
+[operation] linkLibraryCycle
+ package:test/test.dart
+ hashForRequirements: #H0
+ declaredConflicts
+ foo: #M0
+ foo=: #M0
+ exportMapId: #M1
+ exportMap
+ foo: #M0
+ foo=: #M0
+''',
+ updatedCode: r'''
+void foo() {}
+void foo() {}
+void foo() {}
+class B {}
+''',
+ expectedUpdatedEvents: r'''
+[operation] linkLibraryCycle
+ package:test/test.dart
+ hashForRequirements: #H1
+ declaredConflicts
+ foo: #M2
+ foo=: #M2
+ declaredClasses
+ B: #M3
+ interface: #M4
+ exportMapId: #M5
+ exportMap
+ B: #M3
+ foo: #M2
+ foo=: #M2
+''',
+ );
+ }
+
+ test_manifest_topConflict_topVariable_class() async {
+ await _runLibraryManifestScenario(
+ initialCode: r'''
+int A = 0;
+class A {}
+''',
+ expectedInitialEvents: r'''
+[operation] linkLibraryCycle SDK
+[operation] linkLibraryCycle
+ package:test/test.dart
+ hashForRequirements: #H0
+ declaredConflicts
+ A: #M0
+ A=: #M0
+ exportMapId: #M1
+ exportMap
+ A: #M0
+ A=: #M0
+''',
+ updatedCode: r'''
+int A = 0;
+class A {}
+class B {}
+''',
+ expectedUpdatedEvents: r'''
+[operation] linkLibraryCycle
+ package:test/test.dart
+ hashForRequirements: #H1
+ declaredConflicts
+ A: #M2
+ A=: #M2
+ declaredClasses
+ B: #M3
+ interface: #M4
+ exportMapId: #M5
+ exportMap
+ A: #M2
+ A=: #M2
+ B: #M3
+''',
+ );
+ }
+
+ test_manifest_topConflict_topVariable_final_setter() async {
+ await _runLibraryManifestScenario(
+ initialCode: r'''
+final int foo = 0;
+set foo(int _) {}
+''',
+ expectedInitialEvents: r'''
+[operation] linkLibraryCycle SDK
+[operation] linkLibraryCycle
+ package:test/test.dart
+ hashForRequirements: #H0
+ declaredGetters
+ foo: #M0
+ declaredSetters
+ foo=: #M1
+ declaredVariables
+ foo: #M2
+ exportMapId: #M3
+ exportMap
+ foo: #M0
+ foo=: #M1
+''',
+ updatedCode: r'''
+final int foo = 0;
+set foo(int _) {}
+class B {}
+''',
+ expectedUpdatedEvents: r'''
+[operation] linkLibraryCycle
+ package:test/test.dart
+ hashForRequirements: #H1
+ declaredClasses
+ B: #M4
+ interface: #M5
+ declaredGetters
+ foo: #M0
+ declaredSetters
+ foo=: #M1
+ declaredVariables
+ foo: #M2
+ exportMapId: #M6
+ exportMap
+ B: #M4
+ foo: #M0
+ foo=: #M1
+''',
+ );
+ }
+
+ test_manifest_topConflict_topVariable_notFinal_getter() async {
+ await _runLibraryManifestScenario(
+ initialCode: r'''
+int foo = 0;
+int get foo => 0;
+''',
+ expectedInitialEvents: r'''
+[operation] linkLibraryCycle SDK
+[operation] linkLibraryCycle
+ package:test/test.dart
+ hashForRequirements: #H0
+ declaredConflicts
+ foo: #M0
+ foo=: #M0
+ exportMapId: #M1
+ exportMap
+ foo: #M0
+ foo=: #M0
+''',
+ updatedCode: r'''
+int foo = 0;
+int get foo => 0;
+class B {}
+''',
+ expectedUpdatedEvents: r'''
+[operation] linkLibraryCycle
+ package:test/test.dart
+ hashForRequirements: #H1
+ declaredConflicts
+ foo: #M2
+ foo=: #M2
+ declaredClasses
+ B: #M3
+ interface: #M4
+ exportMapId: #M5
+ exportMap
+ B: #M3
+ foo: #M2
+ foo=: #M2
+''',
+ );
+ }
+
+ test_manifest_topConflict_topVariable_notFinal_setter() async {
+ await _runLibraryManifestScenario(
+ initialCode: r'''
+int foo = 0;
+set foo(int _) {}
+''',
+ expectedInitialEvents: r'''
+[operation] linkLibraryCycle SDK
+[operation] linkLibraryCycle
+ package:test/test.dart
+ hashForRequirements: #H0
+ declaredConflicts
+ foo: #M0
+ foo=: #M0
+ exportMapId: #M1
+ exportMap
+ foo: #M0
+ foo=: #M0
+''',
+ updatedCode: r'''
+int foo = 0;
+set foo(int _) {}
+class B {}
+''',
+ expectedUpdatedEvents: r'''
+[operation] linkLibraryCycle
+ package:test/test.dart
+ hashForRequirements: #H1
+ declaredConflicts
+ foo: #M2
+ foo=: #M2
+ declaredClasses
+ B: #M3
+ interface: #M4
+ exportMapId: #M5
+ exportMap
+ B: #M3
+ foo: #M2
+ foo=: #M2
+''',
+ );
+ }
+
+ test_manifest_topConflict_topVariable_topVariable_topVariable() async {
+ await _runLibraryManifestScenario(
+ initialCode: r'''
+int foo = 0;
+int foo = 0;
+int foo = 0;
+''',
+ expectedInitialEvents: r'''
+[operation] linkLibraryCycle SDK
+[operation] linkLibraryCycle
+ package:test/test.dart
+ hashForRequirements: #H0
+ declaredConflicts
+ foo: #M0
+ foo=: #M0
+ exportMapId: #M1
+ exportMap
+ foo: #M0
+ foo=: #M0
+''',
+ updatedCode: r'''
+int foo = 0;
+int foo = 0;
+int foo = 0;
+class B {}
+''',
+ expectedUpdatedEvents: r'''
+[operation] linkLibraryCycle
+ package:test/test.dart
+ hashForRequirements: #H1
+ declaredConflicts
+ foo: #M2
+ foo=: #M2
+ declaredClasses
+ B: #M3
+ interface: #M4
+ exportMapId: #M5
+ exportMap
+ B: #M3
+ foo: #M2
+ foo=: #M2
+''',
+ );
+ }
+
+ test_manifest_topConflict_typeAlias_typeAlias_typeAlias() async {
+ await _runLibraryManifestScenario(
+ initialCode: r'''
+typedef A = int;
+typedef A = int;
+typedef A = int;
+''',
+ expectedInitialEvents: r'''
+[operation] linkLibraryCycle SDK
+[operation] linkLibraryCycle
+ package:test/test.dart
+ hashForRequirements: #H0
+ declaredConflicts
+ A: #M0
+ A=: #M0
+ exportMapId: #M1
+ exportMap
+ A: #M0
+ A=: #M0
+''',
+ updatedCode: r'''
+typedef A = int;
+typedef A = int;
+typedef A = int;
+class B {}
+''',
+ expectedUpdatedEvents: r'''
+[operation] linkLibraryCycle
+ package:test/test.dart
+ hashForRequirements: #H1
+ declaredConflicts
+ A: #M2
+ A=: #M2
+ declaredClasses
+ B: #M3
+ interface: #M4
+ exportMapId: #M5
+ exportMap
+ A: #M2
+ A=: #M2
+ B: #M3
+''',
+ );
+ }
+
test_manifest_topLevelFunction_add() async {
await _runLibraryManifestScenario(
initialCode: r'''
diff --git a/pkg/analyzer/test/src/dart/analysis/result_printer.dart b/pkg/analyzer/test/src/dart/analysis/result_printer.dart
index 626352b..be8e3fd 100644
--- a/pkg/analyzer/test/src/dart/analysis/result_printer.dart
+++ b/pkg/analyzer/test/src/dart/analysis/result_printer.dart
@@ -1143,6 +1143,11 @@
sink.writelnWithIndent('libraryMetadata: $idStr');
}
+ var declaredConflicts = manifest.declaredConflicts.sorted;
+ sink.writeElements('declaredConflicts', declaredConflicts, (entry) {
+ _writelnIdLookupName(entry.key, entry.value);
+ });
+
var classEntries = manifest.declaredClasses.sorted;
sink.writeElements('declaredClasses', classEntries, (entry) {
var item = entry.value;