-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
Given the following:
class C {
final String string;
const C({required this.string});
}
void f() {
const C(string: 0);
}The analyzer currently produces two diagnostics:
A value of type 'int' can't be assigned to a parameter of type 'String' in a const constructor. (const_constructor_param_type_mismatch)
The argument type 'int' can't be assigned to the parameter type 'String'. (argument_type_not_assignable)
Both are reporting the same problem: that an int can't be assigned to a String.
There should only be one diagnostic because there's only one problem. Given that the problem has nothing to do with it being a const constructor, the const_constructor_param_type_mismatch should be suppressed.
Also, the two diagnostics have different highlight ranges. The argument_type_not_assignable highlights the value 0, while the const_constructor_param_type_mismatch includes the argument name in the range (string: 0). Given that there's nothing wrong with the argument name, const_constructor_param_type_mismatch should be changed to highlight only the value of the argument and not include the name.