Skip to content

Commit ef147c0

Browse files
scheglovcommit-bot@chromium.org
authored andcommitted
Issue 42699. Stop reporting EXPORT_DUPLICATED_LIBRARY_NAMED and IMPORT_DUPLICATED_LIBRARY_NAMED.
Bug: #42699 Change-Id: Ie64405791f15a38f170206a11eabee176b6cbfad Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/154540 Reviewed-by: Brian Wilkerson <[email protected]> Commit-Queue: Konstantin Shcheglov <[email protected]>
1 parent 0cc2d96 commit ef147c0

File tree

6 files changed

+0
-188
lines changed

6 files changed

+0
-188
lines changed

pkg/analyzer/lib/error/error.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -747,7 +747,6 @@ const List<ErrorCode> errorCodeValues = [
747747
// ignore: deprecated_member_use_from_same_package
748748
StaticWarningCode.CONST_WITH_ABSTRACT_CLASS,
749749
StaticWarningCode.DEAD_NULL_AWARE_EXPRESSION,
750-
StaticWarningCode.EXPORT_DUPLICATED_LIBRARY_NAMED,
751750
// ignore: deprecated_member_use_from_same_package
752751
StaticWarningCode.EXTRA_POSITIONAL_ARGUMENTS,
753752
// ignore: deprecated_member_use_from_same_package
@@ -762,7 +761,6 @@ const List<ErrorCode> errorCodeValues = [
762761
StaticWarningCode.FINAL_NOT_INITIALIZED_CONSTRUCTOR_3_PLUS,
763762
StaticWarningCode.GETTER_NOT_ASSIGNABLE_SETTER_TYPES,
764763
StaticWarningCode.GETTER_NOT_SUBTYPE_SETTER_TYPES,
765-
StaticWarningCode.IMPORT_DUPLICATED_LIBRARY_NAMED,
766764
// ignore: deprecated_member_use_from_same_package
767765
StaticWarningCode.IMPORT_OF_NON_LIBRARY,
768766
StaticWarningCode.INSTANTIATE_ABSTRACT_CLASS,

pkg/analyzer/lib/src/error/codes.dart

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -8896,23 +8896,6 @@ class StaticWarningCode extends AnalyzerErrorCode {
88968896
errorSeverity: ErrorSeverity.WARNING,
88978897
hasPublishedDocs: true);
88988898

8899-
/**
8900-
* 14.2 Exports: It is a static warning to export two different libraries with
8901-
* the same name.
8902-
*
8903-
* Parameters:
8904-
* 0: the uri pointing to a first library
8905-
* 1: the uri pointing to a second library
8906-
* 2:e the shared name of the exported libraries
8907-
*/
8908-
static const StaticWarningCode EXPORT_DUPLICATED_LIBRARY_NAMED =
8909-
StaticWarningCode(
8910-
'EXPORT_DUPLICATED_LIBRARY_NAMED',
8911-
"The exported libraries '{0}' and '{1}' can't have the same name "
8912-
"'{2}'.",
8913-
correction:
8914-
"Try adding a hide clause to one of the export directives.");
8915-
89168899
@Deprecated('Use CompileTimeErrorCode.EXTRA_POSITIONAL_ARGUMENTS')
89178900
static const CompileTimeErrorCode EXTRA_POSITIONAL_ARGUMENTS =
89188901
CompileTimeErrorCode.EXTRA_POSITIONAL_ARGUMENTS;
@@ -9273,22 +9256,6 @@ class StaticWarningCode extends AnalyzerErrorCode {
92739256
"of the type '{2}' of its setter '{3}'.",
92749257
correction: "Try changing the types so that they are compatible.");
92759258

9276-
/**
9277-
* 14.1 Imports: It is a static warning to import two different libraries with
9278-
* the same name.
9279-
*
9280-
* Parameters:
9281-
* 0: the uri pointing to a first library
9282-
* 1: the uri pointing to a second library
9283-
* 2: the shared name of the imported libraries
9284-
*/
9285-
static const StaticWarningCode IMPORT_DUPLICATED_LIBRARY_NAMED =
9286-
StaticWarningCode(
9287-
'IMPORT_DUPLICATED_LIBRARY_NAMED',
9288-
"The imported libraries '{0}' and '{1}' can't have the same name "
9289-
"'{2}'.",
9290-
correction: "Try adding a hide clause to one of the imports.");
9291-
92929259
@Deprecated('Use CompileTimeErrorCode.IMPORT_OF_NON_LIBRARY')
92939260
static const CompileTimeErrorCode IMPORT_OF_NON_LIBRARY =
92949261
CompileTimeErrorCode.IMPORT_OF_NON_LIBRARY;

pkg/analyzer/lib/src/generated/error_verifier.dart

Lines changed: 0 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -196,16 +196,6 @@ class ErrorVerifier extends RecursiveAstVisitor<void> {
196196
EnclosingExecutableContext _enclosingExecutable =
197197
EnclosingExecutableContext.empty();
198198

199-
/// A table mapping name of the library to the export directive which export
200-
/// this library.
201-
final Map<String, LibraryElement> _nameToExportElement =
202-
HashMap<String, LibraryElement>();
203-
204-
/// A table mapping name of the library to the import directive which import
205-
/// this library.
206-
final Map<String, LibraryElement> _nameToImportElement =
207-
HashMap<String, LibraryElement>();
208-
209199
/// A table mapping names to the exported elements.
210200
final Map<String, Element> _exportedElements = HashMap<String, Element>();
211201

@@ -547,7 +537,6 @@ class ErrorVerifier extends RecursiveAstVisitor<void> {
547537
if (exportElement != null) {
548538
LibraryElement exportedLibrary = exportElement.exportedLibrary;
549539
_checkForAmbiguousExport(node, exportElement, exportedLibrary);
550-
_checkForExportDuplicateLibraryName(node, exportElement, exportedLibrary);
551540
_checkForExportInternalLibrary(node, exportElement);
552541
_checkForExportLegacySymbol(node);
553542
}
@@ -788,7 +777,6 @@ class ErrorVerifier extends RecursiveAstVisitor<void> {
788777
node.prefix, CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_PREFIX_NAME);
789778
}
790779
if (importElement != null) {
791-
_checkForImportDuplicateLibraryName(node, importElement);
792780
_checkForImportInternalLibrary(node, importElement);
793781
if (importElement.isDeferred) {
794782
_checkForDeferredImportOfExtensions(node, importElement);
@@ -2283,38 +2271,6 @@ class ErrorVerifier extends RecursiveAstVisitor<void> {
22832271
return true;
22842272
}
22852273

2286-
/// Verify that the given export [directive] has a unique name among other
2287-
/// exported libraries. The [exportElement] is the [ExportElement] retrieved
2288-
/// from the node, if the element in the node was `null`, then this method is
2289-
/// not called. The [exportedLibrary] is the library element containing the
2290-
/// exported element.
2291-
///
2292-
/// See [CompileTimeErrorCode.EXPORT_DUPLICATED_LIBRARY_NAME].
2293-
void _checkForExportDuplicateLibraryName(ExportDirective directive,
2294-
ExportElement exportElement, LibraryElement exportedLibrary) {
2295-
if (exportedLibrary == null) {
2296-
return;
2297-
}
2298-
String name = exportedLibrary.name;
2299-
// check if there is other exported library with the same name
2300-
LibraryElement prevLibrary = _nameToExportElement[name];
2301-
if (prevLibrary != null) {
2302-
if (prevLibrary != exportedLibrary) {
2303-
if (name.isNotEmpty) {
2304-
_errorReporter.reportErrorForNode(
2305-
StaticWarningCode.EXPORT_DUPLICATED_LIBRARY_NAMED, directive, [
2306-
prevLibrary.definingCompilationUnit.source.uri.toString(),
2307-
exportedLibrary.definingCompilationUnit.source.uri.toString(),
2308-
name
2309-
]);
2310-
}
2311-
return;
2312-
}
2313-
} else {
2314-
_nameToExportElement[name] = exportedLibrary;
2315-
}
2316-
}
2317-
23182274
/// Check that if the visiting library is not system, then any given library
23192275
/// should not be SDK internal library. The [exportElement] is the
23202276
/// [ExportElement] retrieved from the node, if the element in the node was
@@ -2771,36 +2727,6 @@ class ErrorVerifier extends RecursiveAstVisitor<void> {
27712727
}
27722728
}
27732729

2774-
/// Verify that the given import [directive] has a unique name among other
2775-
/// imported libraries. The [importElement] is the [ImportElement] retrieved
2776-
/// from the node, if the element in the node was `null`, then this method is
2777-
/// not called.
2778-
///
2779-
/// See [CompileTimeErrorCode.IMPORT_DUPLICATED_LIBRARY_NAME].
2780-
void _checkForImportDuplicateLibraryName(
2781-
ImportDirective directive, ImportElement importElement) {
2782-
// prepare imported library
2783-
LibraryElement nodeLibrary = importElement.importedLibrary;
2784-
if (nodeLibrary == null) {
2785-
return;
2786-
}
2787-
String name = nodeLibrary.name;
2788-
// check if there is another imported library with the same name
2789-
LibraryElement prevLibrary = _nameToImportElement[name];
2790-
if (prevLibrary != null) {
2791-
if (prevLibrary != nodeLibrary && name.isNotEmpty) {
2792-
_errorReporter.reportErrorForNode(
2793-
StaticWarningCode.IMPORT_DUPLICATED_LIBRARY_NAMED, directive, [
2794-
prevLibrary.definingCompilationUnit.source.uri,
2795-
nodeLibrary.definingCompilationUnit.source.uri,
2796-
name
2797-
]);
2798-
}
2799-
} else {
2800-
_nameToImportElement[name] = nodeLibrary;
2801-
}
2802-
}
2803-
28042730
/// Check that if the visiting library is not system, then any given library
28052731
/// should not be SDK internal library. The [importElement] is the
28062732
/// [ImportElement] retrieved from the node, if the element in the node was

pkg/analyzer/test/src/diagnostics/export_duplicated_library_named_test.dart

Lines changed: 0 additions & 38 deletions
This file was deleted.

pkg/analyzer/test/src/diagnostics/import_duplicated_library_named_test.dart

Lines changed: 0 additions & 35 deletions
This file was deleted.

pkg/analyzer/test/src/diagnostics/test_all.dart

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,6 @@ import 'expected_one_set_type_arguments_test.dart'
126126
as expected_one_set_type_arguments;
127127
import 'expected_two_map_type_arguments_test.dart'
128128
as expected_two_map_type_arguments;
129-
import 'export_duplicated_library_named_test.dart'
130-
as export_duplicated_library_named;
131129
import 'export_internal_library_test.dart' as export_internal_library;
132130
import 'export_legacy_symbol_test.dart' as export_legacy_symbol;
133131
import 'export_of_non_library_test.dart' as export_of_non_library;
@@ -206,8 +204,6 @@ import 'implicit_this_reference_in_initializer_test.dart'
206204
as implicit_this_reference_in_initializer;
207205
import 'import_deferred_library_with_load_function_test.dart'
208206
as import_deferred_library_with_load_function;
209-
import 'import_duplicated_library_named_test.dart'
210-
as import_duplicated_library_named;
211207
import 'import_of_non_library_test.dart' as import_of_non_library;
212208
import 'inconsistent_case_expression_types_test.dart'
213209
as inconsistent_case_expression_types;
@@ -687,7 +683,6 @@ main() {
687683
expected_one_list_type_arguments.main();
688684
expected_one_set_type_arguments.main();
689685
expected_two_map_type_arguments.main();
690-
export_duplicated_library_named.main();
691686
export_internal_library.main();
692687
export_legacy_symbol.main();
693688
export_of_non_library.main();
@@ -737,7 +732,6 @@ main() {
737732
implements_super_class.main();
738733
implicit_this_reference_in_initializer.main();
739734
import_deferred_library_with_load_function.main();
740-
import_duplicated_library_named.main();
741735
import_of_non_library.main();
742736
inconsistent_case_expression_types.main();
743737
inconsistent_inheritance_getter_and_method.main();

0 commit comments

Comments
 (0)