@@ -15,6 +15,7 @@ import 'package:analyzer/src/dart/element/name_union.dart';
1515import 'package:analyzer/src/fine/library_manifest.dart' ;
1616import 'package:analyzer/src/summary2/bundle_writer.dart' ;
1717import 'package:analyzer/src/summary2/detach_nodes.dart' ;
18+ import 'package:analyzer/src/summary2/export.dart' ;
1819import 'package:analyzer/src/summary2/library_builder.dart' ;
1920import 'package:analyzer/src/summary2/linked_element_factory.dart' ;
2021import 'package:analyzer/src/summary2/reference.dart' ;
@@ -179,19 +180,47 @@ class Linker {
179180 }
180181 }
181182
182- while (true ) {
183- var hasChanges = false ;
183+ // We keep a queue of exports to propagate.
184+ // First we loop over every reference that both exports and is exported,
185+ // but then we only process the exports that should be propagated.
186+ var additionalExportData = < _AdditionalExport > [];
187+
188+ void addExport (Export export, String name, ExportedReference reference) {
189+ if (export.addToExportScope (name, reference)) {
190+ // We've added [name] to [export.exporter]s export scope.
191+ // We need to propagate that to anyone that exports that library.
192+ additionalExportData
193+ .add (_AdditionalExport (export.exporter, name, reference));
194+ }
195+ }
196+
197+ for (var exported in both) {
198+ for (var export in exported.exports) {
199+ exported.exportScope.forEach ((name, reference) {
200+ addExport (export, name, reference);
201+ });
202+ }
203+ }
204+
205+ while (additionalExportData.isNotEmpty) {
206+ var data = additionalExportData.removeLast ();
207+ for (var export in data.exported.exports) {
208+ addExport (export, data.name, data.reference);
209+ }
210+ }
211+
212+ assert (() {
184213 for (var exported in both) {
185214 for (var export in exported.exports) {
186215 exported.exportScope.forEach ((name, reference) {
187216 if (export.addToExportScope (name, reference)) {
188- hasChanges = true ;
217+ throw "Error in export calculation: Assert failed." ;
189218 }
190219 });
191220 }
192221 }
193- if ( ! hasChanges) break ;
194- }
222+ return true ;
223+ }(), true );
195224
196225 for (var library in builders.values) {
197226 library.storeExportScope ();
@@ -362,3 +391,11 @@ class LinkResult {
362391 required this .resolutionBytes,
363392 });
364393}
394+
395+ class _AdditionalExport {
396+ final LibraryBuilder exported;
397+ final String name;
398+ final ExportedReference reference;
399+
400+ _AdditionalExport (this .exported, this .name, this .reference);
401+ }
0 commit comments