[beta] 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 <scheglov@google.com>
> Commit-Queue: Samuel Rawlins <srawlins@google.com>
> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Bug: https://github.com/dart-lang/sdk/issues/56872
Change-Id: I613695e90c96e5ffdb4dc56e729dc34be385f5fe
Cherry-pick: https://dart-review.googlesource.com/c/sdk/+/388823
Cherry-pick-request: https://github.com/dart-lang/sdk/issues/56872
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/388842
Commit-Queue: Alexander Thomas <athom@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
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 1fcdf41..27f02b5 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 @@
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 b5fb4a4..30d44f6 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 _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 dbb2b44..6e3f949 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 @@
}
''', 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 7a50e6e..0896322 100644
--- a/pkg/analyzer/lib/error/listener.dart
+++ b/pkg/analyzer/lib/error/listener.dart
@@ -11,10 +11,8 @@
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 @@
return;
}
- if (arguments != null) {
- var invalid = arguments
- .whereNotType<String>()
- .whereNotType<DartType>()
- .whereNotType<Element>()
- .whereNotType<int>()
- .whereNotType<Uri>();
- 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 @@
);
}
- /// 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
- /// clarify the message.
- List<DiagnosticMessage> _convertTypeNames(List<Object?>? arguments) {
+ /// Convert all [Element]s in the [arguments] into their display strings.
+ void _convertElements(List<Object>? arguments) {
if (arguments == null) {
- return const [];
+ return;
}
- var typeGroups = <String, List<_ToConvert>>{};
for (var 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, () => []);
- 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));
+ 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<DiagnosticMessage> _convertTypeNames(List<Object?>? arguments) {
var messages = <DiagnosticMessage>[];
- for (var typeGroup in typeGroups.values) {
+ if (arguments == null) {
+ return messages;
+ }
+
+ Map<String, List<_TypeToConvert>> typeGroups = {};
+ for (int i = 0; i < arguments.length; i++) {
+ var argument = arguments[i];
+ if (argument is TypeImpl) {
+ String displayName = argument.getDisplayString(
+ preferTypeAlias: true,
+ );
+ List<_TypeToConvert> types =
+ typeGroups.putIfAbsent(displayName, () => <_TypeToConvert>[]);
+ types.add(_TypeToConvert(i, argument, displayName));
+ }
+ }
+ 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 = <String, Set<Element>>{};
- for (var typeToConvert in typeGroup) {
- for (var element in typeToConvert.allElements) {
- var 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(', ');
- }
- buffer.write('$name is defined in $sourcePath');
+ } else {
+ Map<String, Set<Element>> nameToElementMap = {};
+ for (_TypeToConvert typeToConvert in typeGroup) {
+ for (Element element in typeToConvert.allElements()) {
+ Set<Element> elements =
+ nameToElementMap.putIfAbsent(element.name!, () => <Element>{});
+ elements.add(element);
}
- messages.add(DiagnosticMessageImpl(
- filePath: element.source!.fullName,
- length: element.nameLength,
- message: '$name is defined in $sourcePath',
- offset: element.nameOffset,
- url: null,
- ));
}
+ 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}');
+ }
+ messages.add(DiagnosticMessageImpl(
+ filePath: element.source!.fullName,
+ length: element.nameLength,
+ message: '$name is defined in ${element.source!.fullName}',
+ 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 @@
}
}
-/// 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<Element> allElements;
-
- _ElementToConvert(this.index, Element element, this.displayName)
- : allElements = [element];
-}
-
/// An [AnalysisErrorListener] that ignores error.
class _NullErrorListener implements AnalysisErrorListener {
@override
@@ -475,61 +461,42 @@
}
}
-/// 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<Element> 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;
-
- @override
+ final DartType type;
final String displayName;
- @override
- late final Iterable<Element> allElements = () {
- var elements = <Element>{};
+ List<Element>? _allElements;
- 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);
+ _TypeToConvert(this.index, this.type, this.displayName);
+
+ List<Element> allElements() {
+ if (_allElements == null) {
+ Set<Element> elements = <Element>{};
+
+ 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);
+ _allElements = elements.where((element) {
+ var name = element.name;
+ return name != null && name.isNotEmpty;
+ }).toList();
}
-
- addElementsFrom(_type);
- return elements.where((element) {
- var name = element.name;
- return name != null && name.isNotEmpty;
- });
- }();
-
- _TypeToConvert(this.index, this._type, this.displayName);
+ 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 789b233..1f51888 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 @@
}
// 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 ec12582..343e8e5 100644
--- a/pkg/analyzer/lib/src/error/codes.g.dart
+++ b/pkg/analyzer/lib/src/error/codes.g.dart
@@ -70,31 +70,14 @@
/// 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(
+ static const CompileTimeErrorCode AMBIGUOUS_EXTENSION_MEMBER_ACCESS =
+ 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 =
- CompileTimeErrorCode(
- 'AMBIGUOUS_EXTENSION_MEMBER_ACCESS',
- "A member named '{0}' is defined in '{1}' and '{2}', and neither is 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 407af9ca..c207246 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 @@
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 1ead2a7..15aeb69d 100644
--- a/pkg/analyzer/messages.yaml
+++ b/pkg/analyzer/messages.yaml
@@ -408,16 +408,14 @@
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 @@
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 7995377..c96edd7 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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
t.foo;
}
''', [
- error(CompileTimeErrorCode.AMBIGUOUS_EXTENSION_MEMBER_ACCESS_TWO, 396, 3),
+ error(CompileTimeErrorCode.AMBIGUOUS_EXTENSION_MEMBER_ACCESS, 396, 3),
]);
}
@@ -368,7 +331,7 @@
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 @@
a += 0;
}
''', [
- error(CompileTimeErrorCode.AMBIGUOUS_EXTENSION_MEMBER_ACCESS_TWO, 130, 2),
+ error(CompileTimeErrorCode.AMBIGUOUS_EXTENSION_MEMBER_ACCESS, 130, 2),
]);
}
@@ -406,7 +369,7 @@
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 @@
0[1] += 2;
}
''', [
- error(CompileTimeErrorCode.AMBIGUOUS_EXTENSION_MEMBER_ACCESS_TWO, 136, 1),
+ error(CompileTimeErrorCode.AMBIGUOUS_EXTENSION_MEMBER_ACCESS, 136, 1),
]);
}
@@ -442,7 +405,7 @@
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 @@
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 g(List<A> x) => x();
int h(List<B> x) => x();
''', [
- error(CompileTimeErrorCode.AMBIGUOUS_EXTENSION_MEMBER_ACCESS_TWO, 167, 1,
+ error(CompileTimeErrorCode.AMBIGUOUS_EXTENSION_MEMBER_ACCESS, 167, 1,
messageContains: [
- "'extension on List<A>' and 'extension on List<B>',"
+ "in unnamed extension on 'List<A>' and unnamed extension on "
+ "'List<B>',"
]),
]);
}
diff --git a/pkg/analyzer/tool/diagnostics/diagnostics.md b/pkg/analyzer/tool/diagnostics/diagnostics.md
index 9062916..e5611dc 100644
--- a/pkg/analyzer/tool/diagnostics/diagnostics.md
+++ b/pkg/analyzer/tool/diagnostics/diagnostics.md
@@ -430,9 +430,6 @@
### 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