diff --git a/pkg/analyzer/lib/src/dart/analysis/driver.dart b/pkg/analyzer/lib/src/dart/analysis/driver.dart index 98a6fc926c4..0133ec9d261 100644 --- a/pkg/analyzer/lib/src/dart/analysis/driver.dart +++ b/pkg/analyzer/lib/src/dart/analysis/driver.dart @@ -96,7 +96,7 @@ import 'package:meta/meta.dart'; // 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 = 386; + static const int DATA_VERSION = 387; /// 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/summary2/bundle_reader.dart b/pkg/analyzer/lib/src/summary2/bundle_reader.dart index bad82cf14b9..1002d11419c 100644 --- a/pkg/analyzer/lib/src/summary2/bundle_reader.dart +++ b/pkg/analyzer/lib/src/summary2/bundle_reader.dart @@ -1016,7 +1016,7 @@ class LibraryReader { ExportLocation _readExportLocation() { return ExportLocation( - containerIndex: _reader.readUInt30(), + fragmentIndex: _reader.readUInt30(), exportIndex: _reader.readUInt30(), ); } diff --git a/pkg/analyzer/lib/src/summary2/bundle_writer.dart b/pkg/analyzer/lib/src/summary2/bundle_writer.dart index f2ad8af625d..b980f5613bc 100644 --- a/pkg/analyzer/lib/src/summary2/bundle_writer.dart +++ b/pkg/analyzer/lib/src/summary2/bundle_writer.dart @@ -317,7 +317,7 @@ class BundleWriter { } void _writeExportLocation(ExportLocation location) { - _sink.writeUInt30(location.containerIndex); + _sink.writeUInt30(location.fragmentIndex); _sink.writeUInt30(location.exportIndex); } diff --git a/pkg/analyzer/lib/src/summary2/export.dart b/pkg/analyzer/lib/src/summary2/export.dart index 2d1a7f0ad38..439e7155a90 100644 --- a/pkg/analyzer/lib/src/summary2/export.dart +++ b/pkg/analyzer/lib/src/summary2/export.dart @@ -76,39 +76,33 @@ class ExportedReferenceExported extends ExportedReference { } class ExportLocation { - /// The index of the container with the `export` directive, `0` means the - /// library itself, a positive value means a `+1` index in the library - /// augmentations. - final int containerIndex; + /// The index of the fragment with the `export` directive, `0` means the + /// library file, a positive value means an included fragment. + final int fragmentIndex; /// The index in [LibraryElementImpl.libraryExports]. final int exportIndex; ExportLocation({ - required this.containerIndex, + required this.fragmentIndex, required this.exportIndex, }); @override bool operator ==(Object other) { return other is ExportLocation && - other.containerIndex == containerIndex && + other.fragmentIndex == fragmentIndex && other.exportIndex == exportIndex; } LibraryExportElementImpl exportOf(LibraryElementImpl library) { - // TODO(scheglov): support for exports from parts - assert(containerIndex == 0); - return library.libraryExports[exportIndex]; - // var container = containerIndex == 0 - // ? library - // : library.augmentations[containerIndex - 1]; - // return container.libraryExports[exportIndex]; + var fragment = library.units[fragmentIndex]; + return fragment.libraryExports[exportIndex]; } @override String toString() { - return '($containerIndex, $exportIndex)'; + return '($fragmentIndex, $exportIndex)'; } } diff --git a/pkg/analyzer/lib/src/summary2/library_builder.dart b/pkg/analyzer/lib/src/summary2/library_builder.dart index 4f71c1eb8ae..4572d7a2cb4 100644 --- a/pkg/analyzer/lib/src/summary2/library_builder.dart +++ b/pkg/analyzer/lib/src/summary2/library_builder.dart @@ -142,7 +142,7 @@ class LibraryBuilder with MacroApplicationsContainer { var export = Export( exporter: this, location: ExportLocation( - containerIndex: fragmentIndex, + fragmentIndex: fragmentIndex, exportIndex: exportIndex, ), combinators: combinators, diff --git a/pkg/analyzer/test/src/diagnostics/deprecated_export_use_test.dart b/pkg/analyzer/test/src/diagnostics/deprecated_export_use_test.dart index b45f79053f3..254d313fff6 100644 --- a/pkg/analyzer/test/src/diagnostics/deprecated_export_use_test.dart +++ b/pkg/analyzer/test/src/diagnostics/deprecated_export_use_test.dart @@ -330,6 +330,27 @@ void f() { ]); } + test_notDeprecated_class_exportedFromPart() async { + newFile('$testPackageLibPath/a.dart', r''' +class A {} +'''); + + newFile('$testPackageLibPath/b.dart', r''' +part of 'c.dart'; +export 'a.dart'; +'''); + + newFile('$testPackageLibPath/c.dart', r''' +part 'b.dart'; +'''); + + await assertNoErrorsInCode(''' +import 'c.dart'; + +void f(A a) {} +'''); + } + test_notDeprecated_class_hasDirectImport() async { newFile('$testPackageLibPath/a.dart', r''' class A {}