-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
Consider the following library:
class C {
C.x();
static set x(_) {}
static get x => 1;
}
The rules about class member conflicts imply that there is an error in this library because the class C
declares both a constructor named C.x
and a static setter whose basename is x
, and another error because it declares both that constructor an a static getter with the same basename.
However, the analyzer (commit 9fced4c) reports the following error:
Analyzing n006.dart...
error • 'x' can't be used to name both a constructor and a static field in this class. • n006.dart:2:5 • conflicting_constructor_and_static_member
1 error found.
The same error is reported if the setter is deleted (such that only the conflict with the getter exists), and also if the getter is deleted (where only the conflict with the setter exists).
I think this is confusing, because there is no variable declaration in C
at all; it would probably be helpful if the error message were adjusted to mention the getter and/or setter explicitly when it/they are declared explicitly, and only talk about a variable declaration in the case where it actually exists.