From d4aa30a3baa93cf6b1a674ab61ce0c5353aa0da6 Mon Sep 17 00:00:00 2001 From: Alexander Thomas Date: Tue, 8 Oct 2024 15:07:38 +0000 Subject: [PATCH] Revert "analyzer: Write out qualified extension names in error messages" This reverts commit 10c1d883df50af05e5cd6e78c36c96f8a22eaa72. Reason for revert: g/dart-sdk-rolls/MOLCzv4S-kQ Original change's description: > analyzer: Write out qualified extension names in error messages > > Fixes https://github.com/dart-lang/sdk/issues/56269 > > Change-Id: I025966fd4aa3d7c5b71175321f21f95e8c41f086 > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/388580 > Reviewed-by: Konstantin Shcheglov > Commit-Queue: Samuel Rawlins > Reviewed-by: Brian Wilkerson Change-Id: I613695e90c96e5ffdb4dc56e729dc34be385f5fe Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/388823 Reviewed-by: Samuel Rawlins Reviewed-by: Brian Wilkerson Auto-Submit: Alexander Thomas Bot-Commit: Rubber Stamper Commit-Queue: Samuel Rawlins Commit-Queue: Alexander Thomas --- .../services/correction/error_fix_status.yaml | 4 +- .../src/services/correction/fix_internal.dart | 5 +- .../fix/add_extension_override_test.dart | 2 +- pkg/analyzer/lib/error/listener.dart | 235 ++++++++---------- .../resolver/extension_member_resolver.dart | 42 ++-- pkg/analyzer/lib/src/error/codes.g.dart | 21 +- .../lib/src/error/error_code_values.g.dart | 3 +- pkg/analyzer/messages.yaml | 17 +- ...mbiguous_extension_member_access_test.dart | 80 ++---- pkg/analyzer/tool/diagnostics/diagnostics.md | 3 - 10 files changed, 147 insertions(+), 265 deletions(-) diff --git a/pkg/analysis_server/lib/src/services/correction/error_fix_status.yaml b/pkg/analysis_server/lib/src/services/correction/error_fix_status.yaml index 1fcdf4170d1e..27f02b5b6e7b 100644 --- a/pkg/analysis_server/lib/src/services/correction/error_fix_status.yaml +++ b/pkg/analysis_server/lib/src/services/correction/error_fix_status.yaml @@ -151,9 +151,7 @@ CompileTimeErrorCode.AMBIGUOUS_EXPORT: status: needsFix notes: |- For each exported name, add a fix to hide the name. -CompileTimeErrorCode.AMBIGUOUS_EXTENSION_MEMBER_ACCESS_THREE_OR_MORE: - status: hasFix -CompileTimeErrorCode.AMBIGUOUS_EXTENSION_MEMBER_ACCESS_TWO: +CompileTimeErrorCode.AMBIGUOUS_EXTENSION_MEMBER_ACCESS: status: hasFix CompileTimeErrorCode.AMBIGUOUS_IMPORT: status: needsFix diff --git a/pkg/analysis_server/lib/src/services/correction/fix_internal.dart b/pkg/analysis_server/lib/src/services/correction/fix_internal.dart index b5fb4a489149..30d44f6326fb 100644 --- a/pkg/analysis_server/lib/src/services/correction/fix_internal.dart +++ b/pkg/analysis_server/lib/src/services/correction/fix_internal.dart @@ -747,10 +747,7 @@ final _builtInLintProducers = >{ }; final _builtInNonLintMultiProducers = { - CompileTimeErrorCode.AMBIGUOUS_EXTENSION_MEMBER_ACCESS_TWO: [ - AddExtensionOverride.new, - ], - CompileTimeErrorCode.AMBIGUOUS_EXTENSION_MEMBER_ACCESS_THREE_OR_MORE: [ + CompileTimeErrorCode.AMBIGUOUS_EXTENSION_MEMBER_ACCESS: [ AddExtensionOverride.new, ], CompileTimeErrorCode.ARGUMENT_TYPE_NOT_ASSIGNABLE: [ diff --git a/pkg/analysis_server/test/src/services/correction/fix/add_extension_override_test.dart b/pkg/analysis_server/test/src/services/correction/fix/add_extension_override_test.dart index dbb2b44f17e1..6e3f949f999d 100644 --- a/pkg/analysis_server/test/src/services/correction/fix/add_extension_override_test.dart +++ b/pkg/analysis_server/test/src/services/correction/fix/add_extension_override_test.dart @@ -44,7 +44,7 @@ f() { } ''', expectedNumberOfFixesForKind: 1, errorFilter: (error) { return error.errorCode == - CompileTimeErrorCode.AMBIGUOUS_EXTENSION_MEMBER_ACCESS_TWO; + CompileTimeErrorCode.AMBIGUOUS_EXTENSION_MEMBER_ACCESS; }); } diff --git a/pkg/analyzer/lib/error/listener.dart b/pkg/analyzer/lib/error/listener.dart index 7a50e6ef8c58..089632238617 100644 --- a/pkg/analyzer/lib/error/listener.dart +++ b/pkg/analyzer/lib/error/listener.dart @@ -11,10 +11,8 @@ import 'package:analyzer/dart/element/type.dart'; import 'package:analyzer/diagnostic/diagnostic.dart'; import 'package:analyzer/error/error.dart'; import 'package:analyzer/source/source.dart'; -import 'package:analyzer/src/dart/element/extensions.dart'; import 'package:analyzer/src/dart/element/type.dart'; import 'package:analyzer/src/diagnostic/diagnostic.dart'; -import 'package:analyzer/src/utilities/extensions/collection.dart'; import 'package:meta/meta.dart'; import 'package:source_span/source_span.dart'; @@ -170,19 +168,7 @@ class ErrorReporter { return; } - if (arguments != null) { - var invalid = arguments - .whereNotType() - .whereNotType() - .whereNotType() - .whereNotType() - .whereNotType(); - if (invalid.isNotEmpty) { - throw ArgumentError('Tried to format an error using ' - '${invalid.map((e) => e.runtimeType).join(', ')}'); - } - } - + _convertElements(arguments); contextMessages ??= []; contextMessages.addAll(_convertTypeNames(arguments)); _errorListener.onError( @@ -348,76 +334,92 @@ class ErrorReporter { ); } - /// Given an array of [arguments] that may contain [DartType]s and [Element]s, - /// converts the types and elements into strings by using the display names of - /// each, unless there are two or more types or elements with the same display - /// names, in which case the extended display names will be used in order to + /// Convert all [Element]s in the [arguments] into their display strings. + void _convertElements(List? arguments) { + if (arguments == null) { + return; + } + + for (var i = 0; i < arguments.length; i++) { + var argument = arguments[i]; + if (argument is Element) { + arguments[i] = argument.getDisplayString(); + } else if (!(argument is String || + argument is DartType || + argument is int || + argument is Uri)) { + throw ArgumentError( + 'Tried to format an error using ${argument.runtimeType}'); + } + } + } + + /// Given an array of [arguments] that is expected to contain two or more + /// types, convert the types into strings by using the display names of the + /// types, unless there are two or more types with the same names, in which + /// case the extended display names of the types will be used in order to /// clarify the message. List _convertTypeNames(List? arguments) { + var messages = []; if (arguments == null) { - return const []; + return messages; } - var typeGroups = >{}; - for (var i = 0; i < arguments.length; i++) { + Map> typeGroups = {}; + for (int i = 0; i < arguments.length; i++) { var argument = arguments[i]; if (argument is TypeImpl) { - var displayName = argument.getDisplayString(preferTypeAlias: true); - var types = typeGroups.putIfAbsent(displayName, () => []); + String displayName = argument.getDisplayString( + preferTypeAlias: true, + ); + List<_TypeToConvert> types = + typeGroups.putIfAbsent(displayName, () => <_TypeToConvert>[]); types.add(_TypeToConvert(i, argument, displayName)); - } else if (argument is Element) { - var displayName = argument.getDisplayString(); - var types = typeGroups.putIfAbsent(displayName, () => []); - types.add(_ElementToConvert(i, argument, displayName)); } } - - var messages = []; - for (var typeGroup in typeGroups.values) { + for (List<_TypeToConvert> typeGroup in typeGroups.values) { if (typeGroup.length == 1) { - var typeToConvert = typeGroup[0]; - // If the display name of a type is unambiguous, just replace the type - // in the arguments list with its display name. + _TypeToConvert typeToConvert = typeGroup[0]; arguments[typeToConvert.index] = typeToConvert.displayName; - continue; - } - - var nameToElementMap = >{}; - for (var typeToConvert in typeGroup) { - for (var element in typeToConvert.allElements) { - var elements = nameToElementMap.putIfAbsent(element.name!, () => {}); - elements.add(element); + } else { + Map> nameToElementMap = {}; + for (_TypeToConvert typeToConvert in typeGroup) { + for (Element element in typeToConvert.allElements()) { + Set elements = + nameToElementMap.putIfAbsent(element.name!, () => {}); + elements.add(element); + } } - } - - for (var typeToConvert in typeGroup) { - // TODO(brianwilkerson): When clients do a better job of displaying - // context messages, remove the extra text added to the buffer. - StringBuffer? buffer; - for (var element in typeToConvert.allElements) { - var name = element.name!; - var sourcePath = element.source!.fullName; - if (nameToElementMap[name]!.length > 1) { - if (buffer == null) { - buffer = StringBuffer(); - buffer.write('where '); - } else { - buffer.write(', '); + for (_TypeToConvert typeToConvert in typeGroup) { + // TODO(brianwilkerson): When clients do a better job of displaying + // context messages, remove the extra text added to the buffer. + StringBuffer? buffer; + for (Element element in typeToConvert.allElements()) { + String name = element.name!; + if (nameToElementMap[name]!.length > 1) { + if (buffer == null) { + buffer = StringBuffer(); + buffer.write('where '); + } else { + buffer.write(', '); + } + buffer.write('$name is defined in ${element.source!.fullName}'); } - buffer.write('$name is defined in $sourcePath'); + messages.add(DiagnosticMessageImpl( + filePath: element.source!.fullName, + length: element.nameLength, + message: '$name is defined in ${element.source!.fullName}', + offset: element.nameOffset, + url: null)); } - messages.add(DiagnosticMessageImpl( - filePath: element.source!.fullName, - length: element.nameLength, - message: '$name is defined in $sourcePath', - offset: element.nameOffset, - url: null, - )); - } - arguments[typeToConvert.index] = buffer != null - ? '${typeToConvert.displayName} ($buffer)' - : typeToConvert.displayName; + if (buffer != null) { + arguments[typeToConvert.index] = + '${typeToConvert.displayName} ($buffer)'; + } else { + arguments[typeToConvert.index] = typeToConvert.displayName; + } + } } } return messages; @@ -451,22 +453,6 @@ class RecordingErrorListener implements AnalysisErrorListener { } } -/// Used by [ErrorReporter._convertTypeNames] to keep track of an error argument -/// that is an [Element], that is being converted to a display string. -class _ElementToConvert implements _ToConvert { - @override - final int index; - - @override - final String displayName; - - @override - final Iterable allElements; - - _ElementToConvert(this.index, Element element, this.displayName) - : allElements = [element]; -} - /// An [AnalysisErrorListener] that ignores error. class _NullErrorListener implements AnalysisErrorListener { @override @@ -475,61 +461,42 @@ class _NullErrorListener implements AnalysisErrorListener { } } -/// Used by [ErrorReporter._convertTypeNames] to keep track of an argument that -/// is being converted to a display string. -abstract class _ToConvert { - /// A list of all elements involved in the [DartType] or [Element]'s display - /// string. - Iterable get allElements; - - /// The argument's display string, to replace the argument in the argument - /// list. - String get displayName; - - /// The index of the argument in the argument list. - int get index; -} - -/// Used by [ErrorReporter._convertTypeNames] to keep track of an error argument -/// that is a [DartType], that is being converted to a display string. -class _TypeToConvert implements _ToConvert { - @override +/// Used by `ErrorReporter._convertTypeNames` to keep track of a type that is +/// being converted. +class _TypeToConvert { final int index; + final DartType type; + final String displayName; - final DartType _type; + List? _allElements; - @override - final String displayName; + _TypeToConvert(this.index, this.type, this.displayName); - @override - late final Iterable allElements = () { - var elements = {}; - - void addElementsFrom(DartType type) { - if (type is FunctionType) { - addElementsFrom(type.returnType); - for (var parameter in type.parameters) { - addElementsFrom(parameter.type); - } - } else if (type is RecordType) { - for (var parameter in type.fields) { - addElementsFrom(parameter.type); - } - } else if (type is InterfaceType) { - if (elements.add(type.element)) { - for (var typeArgument in type.typeArguments) { - addElementsFrom(typeArgument); + List allElements() { + if (_allElements == null) { + Set elements = {}; + + void addElementsFrom(DartType type) { + if (type is FunctionType) { + addElementsFrom(type.returnType); + for (ParameterElement parameter in type.parameters) { + addElementsFrom(parameter.type); + } + } else if (type is InterfaceType) { + if (elements.add(type.element)) { + for (DartType typeArgument in type.typeArguments) { + addElementsFrom(typeArgument); + } } } } - } - addElementsFrom(_type); - return elements.where((element) { - var name = element.name; - return name != null && name.isNotEmpty; - }); - }(); - - _TypeToConvert(this.index, this._type, this.displayName); + addElementsFrom(type); + _allElements = elements.where((element) { + var name = element.name; + return name != null && name.isNotEmpty; + }).toList(); + } + return _allElements!; + } } diff --git a/pkg/analyzer/lib/src/dart/resolver/extension_member_resolver.dart b/pkg/analyzer/lib/src/dart/resolver/extension_member_resolver.dart index 789b233b73dc..1f51888cabce 100644 --- a/pkg/analyzer/lib/src/dart/resolver/extension_member_resolver.dart +++ b/pkg/analyzer/lib/src/dart/resolver/extension_member_resolver.dart @@ -117,33 +117,21 @@ class ExtensionMemberResolver { } // The most specific extension is ambiguous. - if (mostSpecific.length == 2) { - _errorReporter.atEntity( - nameEntity, - CompileTimeErrorCode.AMBIGUOUS_EXTENSION_MEMBER_ACCESS_TWO, - arguments: [ - name.name, - mostSpecific[0].extension, - mostSpecific[1].extension, - ], - ); - } else { - _errorReporter.atEntity( - nameEntity, - CompileTimeErrorCode.AMBIGUOUS_EXTENSION_MEMBER_ACCESS_THREE_OR_MORE, - arguments: [ - name.name, - mostSpecific.map((e) { - var name = e.extension.name; - if (name != null) { - return "extension '$name'"; - } - var type = e.extension.extendedType.getDisplayString(); - return "unnamed extension on '$type'"; - }).commaSeparatedWithAnd, - ], - ); - } + _errorReporter.atEntity( + nameEntity, + CompileTimeErrorCode.AMBIGUOUS_EXTENSION_MEMBER_ACCESS, + arguments: [ + name.name, + mostSpecific.map((e) { + var name = e.extension.name; + if (name != null) { + return "extension '$name'"; + } + var type = e.extension.extendedType.getDisplayString(); + return "unnamed extension on '$type'"; + }).commaSeparatedWithAnd, + ], + ); return ResolutionResult.ambiguous; } diff --git a/pkg/analyzer/lib/src/error/codes.g.dart b/pkg/analyzer/lib/src/error/codes.g.dart index ec1258260812..343e8e57afa6 100644 --- a/pkg/analyzer/lib/src/error/codes.g.dart +++ b/pkg/analyzer/lib/src/error/codes.g.dart @@ -70,31 +70,14 @@ class CompileTimeErrorCode extends AnalyzerErrorCode { /// Parameters: /// 0: the name of the member /// 1: the names of the declaring extensions - static const CompileTimeErrorCode - AMBIGUOUS_EXTENSION_MEMBER_ACCESS_THREE_OR_MORE = CompileTimeErrorCode( - 'AMBIGUOUS_EXTENSION_MEMBER_ACCESS', - "A member named '{0}' is defined in {1}, and none are more specific.", - correctionMessage: - "Try using an extension override to specify the extension you want to " - "be chosen.", - hasPublishedDocs: true, - uniqueName: 'AMBIGUOUS_EXTENSION_MEMBER_ACCESS_THREE_OR_MORE', - ); - - /// Parameters: - /// 0: the name of the member - /// 1: the name of the first declaring extension - /// 2: the names of the second declaring extension - static const CompileTimeErrorCode AMBIGUOUS_EXTENSION_MEMBER_ACCESS_TWO = + static const CompileTimeErrorCode AMBIGUOUS_EXTENSION_MEMBER_ACCESS = CompileTimeErrorCode( 'AMBIGUOUS_EXTENSION_MEMBER_ACCESS', - "A member named '{0}' is defined in '{1}' and '{2}', and neither is more " - "specific.", + "A member named '{0}' is defined in {1}, and none are more specific.", correctionMessage: "Try using an extension override to specify the extension you want to " "be chosen.", hasPublishedDocs: true, - uniqueName: 'AMBIGUOUS_EXTENSION_MEMBER_ACCESS_TWO', ); /// Parameters: diff --git a/pkg/analyzer/lib/src/error/error_code_values.g.dart b/pkg/analyzer/lib/src/error/error_code_values.g.dart index 407af9ca1868..c207246da76c 100644 --- a/pkg/analyzer/lib/src/error/error_code_values.g.dart +++ b/pkg/analyzer/lib/src/error/error_code_values.g.dart @@ -49,8 +49,7 @@ const List errorCodeValues = [ CompileTimeErrorCode.ABSTRACT_FIELD_INITIALIZER, CompileTimeErrorCode.ABSTRACT_SUPER_MEMBER_REFERENCE, CompileTimeErrorCode.AMBIGUOUS_EXPORT, - CompileTimeErrorCode.AMBIGUOUS_EXTENSION_MEMBER_ACCESS_THREE_OR_MORE, - CompileTimeErrorCode.AMBIGUOUS_EXTENSION_MEMBER_ACCESS_TWO, + CompileTimeErrorCode.AMBIGUOUS_EXTENSION_MEMBER_ACCESS, CompileTimeErrorCode.AMBIGUOUS_IMPORT, CompileTimeErrorCode.AMBIGUOUS_SET_OR_MAP_LITERAL_BOTH, CompileTimeErrorCode.AMBIGUOUS_SET_OR_MAP_LITERAL_EITHER, diff --git a/pkg/analyzer/messages.yaml b/pkg/analyzer/messages.yaml index 1ead2a7db363..15aeb69d8994 100644 --- a/pkg/analyzer/messages.yaml +++ b/pkg/analyzer/messages.yaml @@ -408,16 +408,14 @@ CompileTimeErrorCode: export 'a.dart'; export 'b.dart' hide C; ``` - AMBIGUOUS_EXTENSION_MEMBER_ACCESS_TWO: - sharedName: AMBIGUOUS_EXTENSION_MEMBER_ACCESS - problemMessage: "A member named '{0}' is defined in '{1}' and '{2}', and neither is more specific." + AMBIGUOUS_EXTENSION_MEMBER_ACCESS: + problemMessage: "A member named '{0}' is defined in {1}, and none are more specific." correctionMessage: Try using an extension override to specify the extension you want to be chosen. hasPublishedDocs: true comment: |- Parameters: 0: the name of the member - 1: the name of the first declaring extension - 2: the names of the second declaring extension + 1: the names of the declaring extensions documentation: |- #### Description @@ -473,15 +471,6 @@ CompileTimeErrorCode: print(E2(s).charCount); } ``` - AMBIGUOUS_EXTENSION_MEMBER_ACCESS_THREE_OR_MORE: - sharedName: AMBIGUOUS_EXTENSION_MEMBER_ACCESS - problemMessage: "A member named '{0}' is defined in {1}, and none are more specific." - correctionMessage: Try using an extension override to specify the extension you want to be chosen. - hasPublishedDocs: true - comment: |- - Parameters: - 0: the name of the member - 1: the names of the declaring extensions AMBIGUOUS_IMPORT: problemMessage: "The name '{0}' is defined in the libraries {1}." correctionMessage: "Try using 'as prefix' for one of the import directives, or hiding the name from all but one of the imports." diff --git a/pkg/analyzer/test/src/diagnostics/ambiguous_extension_member_access_test.dart b/pkg/analyzer/test/src/diagnostics/ambiguous_extension_member_access_test.dart index 79953772b79a..c96edd7e7a4b 100644 --- a/pkg/analyzer/test/src/diagnostics/ambiguous_extension_member_access_test.dart +++ b/pkg/analyzer/test/src/diagnostics/ambiguous_extension_member_access_test.dart @@ -29,7 +29,7 @@ extension E2 on A { int f(A a) => a(); ''', [ - error(CompileTimeErrorCode.AMBIGUOUS_EXTENSION_MEMBER_ACCESS_TWO, 110, 1), + error(CompileTimeErrorCode.AMBIGUOUS_EXTENSION_MEMBER_ACCESS, 110, 1), ]); } @@ -47,7 +47,7 @@ f() { 0.a; } ''', [ - error(CompileTimeErrorCode.AMBIGUOUS_EXTENSION_MEMBER_ACCESS_TWO, 98, 1), + error(CompileTimeErrorCode.AMBIGUOUS_EXTENSION_MEMBER_ACCESS, 98, 1), ]); var node = findNode.propertyAccess('0.a'); @@ -111,7 +111,7 @@ f() { 0.a; } ''', [ - error(CompileTimeErrorCode.AMBIGUOUS_EXTENSION_MEMBER_ACCESS_TWO, 91, 1), + error(CompileTimeErrorCode.AMBIGUOUS_EXTENSION_MEMBER_ACCESS, 91, 1), ]); var node = findNode.propertyAccess('0.a'); @@ -144,7 +144,7 @@ f() { 0.a; } ''', [ - error(CompileTimeErrorCode.AMBIGUOUS_EXTENSION_MEMBER_ACCESS_TWO, 96, 1), + error(CompileTimeErrorCode.AMBIGUOUS_EXTENSION_MEMBER_ACCESS, 96, 1), ]); var node = findNode.propertyAccess('0.a'); @@ -172,38 +172,8 @@ void f() { 0.foo(); } ''', [ - error(CompileTimeErrorCode.AMBIGUOUS_EXTENSION_MEMBER_ACCESS_TWO, 129, 3, - messageContains: [ - "in 'extension E1 on int' and 'extension E2 on int',", - ]), - ]); - } - - test_method_conflict_conflict_notSpecific_sameName() async { - var one = newFile('$testPackageLibPath/one.dart', ''' -extension E on int { void foo() {} } -'''); - var two = newFile('$testPackageLibPath/two.dart', ''' -extension E on int { void foo() {} } -'''); - await assertErrorsInCode(''' -// ignore_for_file: unused_import -import 'one.dart'; -import 'two.dart'; -void f() { - 0.foo(); -} -''', [ - error( - CompileTimeErrorCode.AMBIGUOUS_EXTENSION_MEMBER_ACCESS_TWO, - 87, - 3, - messageContains: [ - "'extension E on int (where E is defined in ${one.path})' and " - "'extension E on int (where E is defined in ${two.path})',", - ], - contextMessages: [message(one, 10, 1), message(two, 10, 1)], - ), + error(CompileTimeErrorCode.AMBIGUOUS_EXTENSION_MEMBER_ACCESS, 129, 3, + messageContains: ["in extension 'E1' and extension 'E2',"]), ]); } @@ -227,10 +197,8 @@ void f() { 0.foo(); } ''', [ - error(CompileTimeErrorCode.AMBIGUOUS_EXTENSION_MEMBER_ACCESS_TWO, 129, 3, - messageContains: [ - "in 'extension E1 on int' and 'extension E2 on int',", - ]), + error(CompileTimeErrorCode.AMBIGUOUS_EXTENSION_MEMBER_ACCESS, 129, 3, + messageContains: ["in extension 'E1' and extension 'E2',"]), ]); } @@ -259,7 +227,7 @@ f() { 0.a(); } ''', [ - error(CompileTimeErrorCode.AMBIGUOUS_EXTENSION_MEMBER_ACCESS_TWO, 88, 1), + error(CompileTimeErrorCode.AMBIGUOUS_EXTENSION_MEMBER_ACCESS, 88, 1), ]); var node = findNode.methodInvocation('0.a()'); @@ -291,10 +259,8 @@ void f() { 0.foo(); } ''', [ - error(CompileTimeErrorCode.AMBIGUOUS_EXTENSION_MEMBER_ACCESS_TWO, 129, 3, - messageContains: [ - "in 'extension E1 on int' and 'extension E2 on int'," - ]), + error(CompileTimeErrorCode.AMBIGUOUS_EXTENSION_MEMBER_ACCESS, 129, 3, + messageContains: ["in extension 'E1' and extension 'E2',"]), ]); } @@ -308,10 +274,7 @@ void f() { 0.foo(); } ''', [ - error( - CompileTimeErrorCode.AMBIGUOUS_EXTENSION_MEMBER_ACCESS_THREE_OR_MORE, - 167, - 3, + error(CompileTimeErrorCode.AMBIGUOUS_EXTENSION_MEMBER_ACCESS, 167, 3, messageContains: [ "in extension 'E1', extension 'E2', and extension 'E3'," ]), @@ -350,7 +313,7 @@ f(SubTarget t) { t.foo; } ''', [ - error(CompileTimeErrorCode.AMBIGUOUS_EXTENSION_MEMBER_ACCESS_TWO, 396, 3), + error(CompileTimeErrorCode.AMBIGUOUS_EXTENSION_MEMBER_ACCESS, 396, 3), ]); } @@ -368,7 +331,7 @@ extension E2 on A { A f(A a) => a + a; ''', [ - error(CompileTimeErrorCode.AMBIGUOUS_EXTENSION_MEMBER_ACCESS_TWO, 122, 5), + error(CompileTimeErrorCode.AMBIGUOUS_EXTENSION_MEMBER_ACCESS, 122, 5), ]); } @@ -388,7 +351,7 @@ void f(A a) { a += 0; } ''', [ - error(CompileTimeErrorCode.AMBIGUOUS_EXTENSION_MEMBER_ACCESS_TWO, 130, 2), + error(CompileTimeErrorCode.AMBIGUOUS_EXTENSION_MEMBER_ACCESS, 130, 2), ]); } @@ -406,7 +369,7 @@ extension E2 on A { int f(A a) => a[0]; ''', [ - error(CompileTimeErrorCode.AMBIGUOUS_EXTENSION_MEMBER_ACCESS_TWO, 134, 1), + error(CompileTimeErrorCode.AMBIGUOUS_EXTENSION_MEMBER_ACCESS, 134, 1), ]); } @@ -424,7 +387,7 @@ f() { 0[1] += 2; } ''', [ - error(CompileTimeErrorCode.AMBIGUOUS_EXTENSION_MEMBER_ACCESS_TWO, 136, 1), + error(CompileTimeErrorCode.AMBIGUOUS_EXTENSION_MEMBER_ACCESS, 136, 1), ]); } @@ -442,7 +405,7 @@ extension E2 on A { int f(A a) => -a; ''', [ - error(CompileTimeErrorCode.AMBIGUOUS_EXTENSION_MEMBER_ACCESS_TWO, 123, 1), + error(CompileTimeErrorCode.AMBIGUOUS_EXTENSION_MEMBER_ACCESS, 123, 1), ]); } @@ -460,7 +423,7 @@ f() { 0.a = 3; } ''', [ - error(CompileTimeErrorCode.AMBIGUOUS_EXTENSION_MEMBER_ACCESS_TWO, 88, 1), + error(CompileTimeErrorCode.AMBIGUOUS_EXTENSION_MEMBER_ACCESS, 88, 1), ]); assertResolvedNodeText(findNode.assignment('= 3'), r''' @@ -513,9 +476,10 @@ int f(List x) => x(); int g(List x) => x(); int h(List x) => x(); ''', [ - error(CompileTimeErrorCode.AMBIGUOUS_EXTENSION_MEMBER_ACCESS_TWO, 167, 1, + error(CompileTimeErrorCode.AMBIGUOUS_EXTENSION_MEMBER_ACCESS, 167, 1, messageContains: [ - "'extension on List' and 'extension on List'," + "in unnamed extension on 'List' and unnamed extension on " + "'List'," ]), ]); } diff --git a/pkg/analyzer/tool/diagnostics/diagnostics.md b/pkg/analyzer/tool/diagnostics/diagnostics.md index 906291688012..e5611dc8f842 100644 --- a/pkg/analyzer/tool/diagnostics/diagnostics.md +++ b/pkg/analyzer/tool/diagnostics/diagnostics.md @@ -430,9 +430,6 @@ export 'b.dart' hide C; ### ambiguous_extension_member_access -_A member named '{0}' is defined in '{1}' and '{2}', and neither is more -specific._ - _A member named '{0}' is defined in {1}, and none are more specific._ #### Description