Open
Description
The error messages generated by this code with an extra < are not very helpful, and appear on lines
much earlier than the error occurs at. The analyzer thinks a field called "Map" is being added to the class.
And the error messages for the error location don't indicate anything about type parameters or <.
Could recovery do a better job by not incorrectly adding this field?
These messages appear on Dart stable 2.9 and dev 2.10.0-45.0.dev
The code is:
class QueryResults extends ChangeNotifier {
Filter filter;
final foo = {1:2};
Map<int, int> bar = {1:2};
bool showAll = true;
List<String> names = [];
Map<String, <Map<String, int>>> counts = {}; // ERROR: extra < before Map.
Map<String, Map<ChangeInResult, List<Result>>> grouped = {};
bool partialResults = true;
}
The error messages are:
error: The instance member 'Map' can't be accessed in an initializer. (implicit_this_reference_in_initializer at [flutter_current_results_a] lib/query.dart:18)
error: Map isn't a type. (not_a_type at [flutter_current_results_a] lib/query.dart:18)
error: A function body must be provided. (missing_function_body at [flutter_current_results_a] lib/query.dart:21)
error: Expected an identifier. (missing_identifier at [flutter_current_results_a] lib/query.dart:21)
error: Variables must be declared using the keywords 'const', 'final', 'var' or a type name. (missing_const_final_var_or_type at [flutter_current_results_a] lib/query.dart:21)
error: Methods must have an explicit list of parameters. (missing_method_parameters at [flutter_current_results_a] lib/query.dart:21)
error: The instance member 'Map' can't be accessed in an initializer. (implicit_this_reference_in_initializer at [flutter_current_results_a] lib/query.dart:22)
error: Map isn't a type. (not_a_type at [flutter_current_results_a] lib/query.dart:22)