-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
Thanks to @athomas for raising this issue. Consider the following program:
extension HashAll on Iterable {
int hashAll() => 0;
}
extension HashAllList on List {
int hashAll() => 1;
}
void main() {
List l = [];
Iterable i = [];
print(l.hashAll());
print(i.hashAll());
}The CFE (using dart from commit 20b5602) reports a conflict with a static member of the class Object:
n008.dart:2:7: Error: This extension member conflicts with Object member 'hashAll'.
int hashAll() {
^^^^^^^
n008.dart:8:7: Error: This extension member conflicts with Object member 'hashAll'.
int hashAll() {
^^^^^^^
However, I cannot find a justification in the specification documents that any such conflict should be reported. Intuitively, it would not be a conflict anyway, because access to the static method hashAll in Object would have to use the syntax Object.hashAll or prefix.Object.hashAll everywhere outside the class Object itself, and those forms cannot be an access to the extension methods shown above (assuming that Object resolves to the built-in class and hasn't been shadowed by declaration like a local variable).
I believe the conflict should not be reported. The behavior is CFE specific, the analyzer doesn't report a conflict.