diff --git a/pkg/_fe_analyzer_shared/lib/src/messages/codes_generated.dart b/pkg/_fe_analyzer_shared/lib/src/messages/codes_generated.dart index 7868cb75c30..96608e07fa2 100644 --- a/pkg/_fe_analyzer_shared/lib/src/messages/codes_generated.dart +++ b/pkg/_fe_analyzer_shared/lib/src/messages/codes_generated.dart @@ -6307,6 +6307,65 @@ const MessageCode messageListLiteralTooManyTypeArguments = const MessageCode( analyzerCodes: ["EXPECTED_ONE_LIST_TYPE_ARGUMENTS"], message: r"""List literal requires exactly one type argument."""); +// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE. +const Template + templateLiteralWithClass = + const Template( + messageTemplate: + r"""A #string literal can't be prefixed by '#lexeme'.""", + tipTemplate: r"""Try removing '#lexeme'""", + withArguments: _withArgumentsLiteralWithClass); + +// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE. +const Code codeLiteralWithClass = + const Code("LiteralWithClass", + index: 116); + +// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE. +Message _withArgumentsLiteralWithClass(String string, Token token) { + if (string.isEmpty) throw 'No string provided'; + String lexeme = token.lexeme; + return new Message(codeLiteralWithClass, + message: """A ${string} literal can't be prefixed by '${lexeme}'.""", + tip: """Try removing '${lexeme}'""", + arguments: {'string': string, 'lexeme': token}); +} + +// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE. +const Template + templateLiteralWithClassAndNew = + const Template( + messageTemplate: + r"""A #string literal can't be prefixed by 'new #lexeme'.""", + tipTemplate: r"""Try removing 'new' and '#lexeme'""", + withArguments: _withArgumentsLiteralWithClassAndNew); + +// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE. +const Code + codeLiteralWithClassAndNew = + const Code( + "LiteralWithClassAndNew", + index: 115); + +// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE. +Message _withArgumentsLiteralWithClassAndNew(String string, Token token) { + if (string.isEmpty) throw 'No string provided'; + String lexeme = token.lexeme; + return new Message(codeLiteralWithClassAndNew, + message: """A ${string} literal can't be prefixed by 'new ${lexeme}'.""", + tip: """Try removing 'new' and '${lexeme}'""", + arguments: {'string': string, 'lexeme': token}); +} + +// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE. +const Code codeLiteralWithNew = messageLiteralWithNew; + +// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE. +const MessageCode messageLiteralWithNew = const MessageCode("LiteralWithNew", + index: 117, + message: r"""A literal can't be prefixed by 'new'.""", + tip: r"""Try removing 'new'"""); + // DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE. const Code codeLoadLibraryTakesNoArguments = messageLoadLibraryTakesNoArguments; diff --git a/pkg/_fe_analyzer_shared/lib/src/parser/parser_impl.dart b/pkg/_fe_analyzer_shared/lib/src/parser/parser_impl.dart index a1749b69ae9..1fe9144c7ac 100644 --- a/pkg/_fe_analyzer_shared/lib/src/parser/parser_impl.dart +++ b/pkg/_fe_analyzer_shared/lib/src/parser/parser_impl.dart @@ -2412,13 +2412,7 @@ class Parser { /// Checks whether the next token is (directly) an identifier. If this returns /// true a call to [ensureIdentifier] will return the next token. - bool isNextIdentifier(Token token) { - Token identifier = token.next!; - if (identifier.kind != IDENTIFIER_TOKEN) { - return false; - } - return true; - } + bool isNextIdentifier(Token token) => token.next?.kind == IDENTIFIER_TOKEN; /// Parse a simple identifier at the given [token], and return the identifier /// that was parsed. @@ -5771,10 +5765,11 @@ class Parser { if (optional('{', afterToken)) { // Recover by ignoring both the `new` and the `Map`/`Set` and parse as // a literal map/set. - reportRecoverableErrorWithToken( - newKeyword, codes.templateUnexpectedToken); - reportRecoverableErrorWithToken( - identifier, codes.templateUnexpectedToken); + reportRecoverableErrorWithEnd( + newKeyword, + identifier, + codes.templateLiteralWithClassAndNew + .withArguments(value.toLowerCase(), identifier)); return parsePrimary(identifier, IdentifierContext.expression); } } else if (value == "List" && !optional('.', identifier.next!)) { @@ -5783,10 +5778,11 @@ class Parser { if (optional('[', afterToken) || optional('[]', afterToken)) { // Recover by ignoring both the `new` and the `List` and parse as // a literal list. - reportRecoverableErrorWithToken( - newKeyword, codes.templateUnexpectedToken); - reportRecoverableErrorWithToken( - identifier, codes.templateUnexpectedToken); + reportRecoverableErrorWithEnd( + newKeyword, + identifier, + codes.templateLiteralWithClassAndNew + .withArguments(value.toLowerCase(), identifier)); return parsePrimary(identifier, IdentifierContext.expression); } } @@ -5804,14 +5800,12 @@ class Parser { optional('[', afterToken) || optional('[]', afterToken)) { // Recover by ignoring the `new` and parse as a literal map/set/list. - reportRecoverableErrorWithToken( - newKeyword, codes.templateUnexpectedToken); + reportRecoverableError(newKeyword, codes.messageLiteralWithNew); return parsePrimary(newKeyword, IdentifierContext.expression); } } else if (value == "{" || value == "[" || value == "[]") { // Recover by ignoring the `new` and parse as a literal map/set/list. - reportRecoverableErrorWithToken( - newKeyword, codes.templateUnexpectedToken); + reportRecoverableError(newKeyword, codes.messageLiteralWithNew); return parsePrimary(newKeyword, IdentifierContext.expression); } } @@ -5886,7 +5880,10 @@ class Parser { final String? nextValue = nextNext.stringValue; if (identical(nextValue, '{')) { // Recover by ignoring the `Map`/`Set` and parse as a literal map/set. - reportRecoverableErrorWithToken(next, codes.templateUnexpectedToken); + reportRecoverableError( + next, + codes.templateLiteralWithClass + .withArguments(lexeme.toLowerCase(), next)); listener.beginConstLiteral(nextNext); listener.handleNoTypeArguments(nextNext); token = parseLiteralSetOrMapSuffix(next, constKeyword); @@ -5895,7 +5892,11 @@ class Parser { } if (identical(nextValue, '<')) { // Recover by ignoring the `Map`/`Set` and parse as a literal map/set. - reportRecoverableErrorWithToken(next, codes.templateUnexpectedToken); + reportRecoverableError( + next, + codes.templateLiteralWithClass + .withArguments(lexeme.toLowerCase(), next)); + listener.beginConstLiteral(nextNext); token = parseLiteralListSetMapOrFunction(next, constKeyword); listener.endConstLiteral(token.next!); @@ -5911,7 +5912,10 @@ class Parser { final String? nextValue = nextNext.stringValue; if (identical(nextValue, '[') || identical(nextValue, '[]')) { // Recover by ignoring the `List` and parse as a literal list. - reportRecoverableErrorWithToken(next, codes.templateUnexpectedToken); + reportRecoverableError( + next, + codes.templateLiteralWithClass + .withArguments(lexeme.toLowerCase(), next)); listener.beginConstLiteral(nextNext); listener.handleNoTypeArguments(nextNext); token = parseLiteralListSuffix(next, constKeyword); @@ -5920,7 +5924,10 @@ class Parser { } if (identical(nextValue, '<')) { // Recover by ignoring the `List` and parse as a literal list. - reportRecoverableErrorWithToken(next, codes.templateUnexpectedToken); + reportRecoverableError( + next, + codes.templateLiteralWithClass + .withArguments(lexeme.toLowerCase(), next)); listener.beginConstLiteral(nextNext); token = parseLiteralListSetMapOrFunction(next, constKeyword); listener.endConstLiteral(token.next!); @@ -6100,8 +6107,10 @@ class Parser { afterToken = potentialTypeArg.skip(identifier).next!; if (optional('{', afterToken)) { // Recover by ignoring the `Map`/`Set` and parse as a literal map/set. - reportRecoverableErrorWithToken( - identifier, codes.templateUnexpectedToken); + reportRecoverableError( + identifier, + codes.templateLiteralWithClass + .withArguments(value.toLowerCase(), identifier)); return parsePrimary(identifier, context); } } else if (value == "List") { @@ -6114,8 +6123,10 @@ class Parser { // Note that we here require the `<...>` for `[` as `List[` would be // an indexed expression. `List[]` wouldn't though, so we don't // require it there. - reportRecoverableErrorWithToken( - identifier, codes.templateUnexpectedToken); + reportRecoverableError( + identifier, + codes.templateLiteralWithClass + .withArguments(value.toLowerCase(), identifier)); return parsePrimary(identifier, context); } } diff --git a/pkg/analyzer/lib/error/error.dart b/pkg/analyzer/lib/error/error.dart index c83a346b5c6..10488ef93ed 100644 --- a/pkg/analyzer/lib/error/error.dart +++ b/pkg/analyzer/lib/error/error.dart @@ -734,6 +734,9 @@ const List errorCodeValues = [ ParserErrorCode.INVALID_UNICODE_ESCAPE, ParserErrorCode.INVALID_USE_OF_COVARIANT_IN_EXTENSION, ParserErrorCode.LIBRARY_DIRECTIVE_NOT_FIRST, + ParserErrorCode.LITERAL_WITH_CLASS_AND_NEW, + ParserErrorCode.LITERAL_WITH_CLASS, + ParserErrorCode.LITERAL_WITH_NEW, ParserErrorCode.LOCAL_FUNCTION_DECLARATION_MODIFIER, ParserErrorCode.MEMBER_WITH_CLASS_NAME, ParserErrorCode.MISSING_ASSIGNABLE_SELECTOR, diff --git a/pkg/analyzer/lib/src/dart/error/syntactic_errors.dart b/pkg/analyzer/lib/src/dart/error/syntactic_errors.dart index e881af82bb4..e1358f16fd1 100644 --- a/pkg/analyzer/lib/src/dart/error/syntactic_errors.dart +++ b/pkg/analyzer/lib/src/dart/error/syntactic_errors.dart @@ -555,6 +555,13 @@ class ParserErrorCode extends ErrorCode { static const ParserErrorCode LIBRARY_DIRECTIVE_NOT_FIRST = _LIBRARY_DIRECTIVE_NOT_FIRST; + static const ParserErrorCode LITERAL_WITH_CLASS_AND_NEW = + _LITERAL_WITH_CLASS_AND_NEW; + + static const ParserErrorCode LITERAL_WITH_CLASS = _LITERAL_WITH_CLASS; + + static const ParserErrorCode LITERAL_WITH_NEW = _LITERAL_WITH_NEW; + static const ParserErrorCode LOCAL_FUNCTION_DECLARATION_MODIFIER = ParserErrorCode('LOCAL_FUNCTION_DECLARATION_MODIFIER', "Local function declarations can't specify any modifiers.", diff --git a/pkg/analyzer/lib/src/dart/error/syntactic_errors.g.dart b/pkg/analyzer/lib/src/dart/error/syntactic_errors.g.dart index 5265c242558..36a49fe75a5 100644 --- a/pkg/analyzer/lib/src/dart/error/syntactic_errors.g.dart +++ b/pkg/analyzer/lib/src/dart/error/syntactic_errors.g.dart @@ -122,6 +122,9 @@ final fastaAnalyzerErrorCodes = [ _BINARY_OPERATOR_WRITTEN_OUT, _EXPECTED_IDENTIFIER_BUT_GOT_KEYWORD, _ANNOTATION_WITH_TYPE_ARGUMENTS_UNINSTANTIATED, + _LITERAL_WITH_CLASS_AND_NEW, + _LITERAL_WITH_CLASS, + _LITERAL_WITH_NEW, ]; const ParserErrorCode _ABSTRACT_CLASS_MEMBER = ParserErrorCode( @@ -474,6 +477,20 @@ const ParserErrorCode _LIBRARY_DIRECTIVE_NOT_FIRST = ParserErrorCode( correction: "Try moving the library directive before any other directives."); +const ParserErrorCode _LITERAL_WITH_CLASS = ParserErrorCode( + 'LITERAL_WITH_CLASS', + r"The name of the class '#lexeme' can't be included in a #string literal.", + correction: "Try removing '#lexeme'"); + +const ParserErrorCode _LITERAL_WITH_CLASS_AND_NEW = ParserErrorCode( + 'LITERAL_WITH_CLASS_AND_NEW', + r"Neither 'new' nor the name of the class '#lexeme' can be included in a #string literal.", + correction: "Try removing 'new' and '#lexeme'"); + +const ParserErrorCode _LITERAL_WITH_NEW = ParserErrorCode( + 'LITERAL_WITH_NEW', r"A literal can't use 'new'.", + correction: "Try removing 'new'"); + const ParserErrorCode _MEMBER_WITH_CLASS_NAME = ParserErrorCode( 'MEMBER_WITH_CLASS_NAME', r"A class member can't have the same name as the enclosing class.", diff --git a/pkg/analyzer/test/generated/recovery_parser_test.dart b/pkg/analyzer/test/generated/recovery_parser_test.dart index b94611575a0..1abb18e7198 100644 --- a/pkg/analyzer/test/generated/recovery_parser_test.dart +++ b/pkg/analyzer/test/generated/recovery_parser_test.dart @@ -1034,7 +1034,13 @@ class C {}; }", codes: [ - ParserErrorCode.UNEXPECTED_TOKEN, + ParserErrorCode.LITERAL_WITH_CLASS, + ]); + parseCompilationUnit("class C { var f = new Map {}; }", codes: [ + ParserErrorCode.LITERAL_WITH_CLASS_AND_NEW, + ]); + parseCompilationUnit("class C { var f = new {}; }", codes: [ + ParserErrorCode.LITERAL_WITH_NEW, ]); } diff --git a/pkg/front_end/messages.yaml b/pkg/front_end/messages.yaml index 302322ad344..c5be3f55d64 100644 --- a/pkg/front_end/messages.yaml +++ b/pkg/front_end/messages.yaml @@ -1248,6 +1248,54 @@ UnexpectedToken: script: - "import 'b.dart' d as b;" +LiteralWithClassAndNew: + template: "A #string literal can't be prefixed by 'new #lexeme'." + tip: "Try removing 'new' and '#lexeme'" + analyzerCode: ParserErrorCode.LITERAL_WITH_CLASS_AND_NEW + index: 115 + script: + - "var x = new Map{};" + - "var x = new Set{};" + - "var x = new List[];" + - "var x = new Map{1: 2};" + - "var x = new Set{1};" + - "var x = new List[1];" + +LiteralWithClass: + template: "A #string literal can't be prefixed by '#lexeme'." + tip: "Try removing '#lexeme'" + analyzerCode: ParserErrorCode.LITERAL_WITH_CLASS + index: 116 + script: + - "var x = Map{};" + - "var x = Set{};" + - "var x = List[];" + - "var x = Map{1: 2};" + - "var x = Set{1};" + - "var x = List[1];" + - "var x = const Map{};" + - "var x = const Set{};" + - "var x = const List[];" + - "var x = const Map{1: 2};" + - "var x = const Set{1};" + - "var x = const List[1];" + +LiteralWithNew: + template: "A literal can't be prefixed by 'new'." + tip: "Try removing 'new'" + analyzerCode: ParserErrorCode.LITERAL_WITH_NEW + index: 117 + script: + - "var x = new {};" + - "var x = new {};" + - "var x = new {};" + - "var x = new [];" + - "var x = new {'a': 'b'};" + - "var x = new {'a'};" + - "var x = new {'a': 'b'};" + - "var x = new {'a'};" + - "var x = new ['a'];" + UnmatchedToken: template: "Can't find '#string' to match '#lexeme'." analyzerCode: EXPECTED_TOKEN diff --git a/pkg/front_end/parser_testcases/error_recovery/issue_45251.dart.expect b/pkg/front_end/parser_testcases/error_recovery/issue_45251.dart.expect index 898cf57c7c7..702b63b8be7 100644 --- a/pkg/front_end/parser_testcases/error_recovery/issue_45251.dart.expect +++ b/pkg/front_end/parser_testcases/error_recovery/issue_45251.dart.expect @@ -1,18 +1,18 @@ Problems reported: -parser/error_recovery/issue_45251:3:39: Unexpected token 'Map'. +parser/error_recovery/issue_45251:3:39: A map literal can't be prefixed by 'Map'. final Map foo1 = Map>{}; ^^^ -parser/error_recovery/issue_45251:9:39: Unexpected token 'Map'. +parser/error_recovery/issue_45251:9:39: A map literal can't be prefixed by 'Map'. final Map foo3 = Map{}; ^^^ -parser/error_recovery/issue_45251:18:39: Unexpected token 'Map'. +parser/error_recovery/issue_45251:18:39: A map literal can't be prefixed by 'Map'. final Map foo6 = Map>{"a": null}; ^^^ -parser/error_recovery/issue_45251:21:39: Unexpected token 'Map'. +parser/error_recovery/issue_45251:21:39: A map literal can't be prefixed by 'Map'. final Map foo7 = Map{"a": null}; ^^^ @@ -45,7 +45,7 @@ beginCompilationUnit(class) handleType(Map, null) handleIdentifier(foo1, fieldDeclaration) beginFieldInitializer(=) - handleRecoverableError(Message[UnexpectedToken, Unexpected token 'Map'., null, {lexeme: Map}], Map, Map) + handleRecoverableError(Message[LiteralWithClass, A map literal can't be prefixed by 'Map'., Try removing 'Map', {string: map, lexeme: Map}], Map, Map) beginTypeArguments(<) handleIdentifier(String, typeReference) handleNoTypeArguments(,) @@ -110,7 +110,7 @@ beginCompilationUnit(class) handleType(Map, null) handleIdentifier(foo3, fieldDeclaration) beginFieldInitializer(=) - handleRecoverableError(Message[UnexpectedToken, Unexpected token 'Map'., null, {lexeme: Map}], Map, Map) + handleRecoverableError(Message[LiteralWithClass, A map literal can't be prefixed by 'Map'., Try removing 'Map', {string: map, lexeme: Map}], Map, Map) handleNoTypeArguments({) handleLiteralSetOrMap(0, {, null, }, false) endFieldInitializer(=, ;) @@ -191,7 +191,7 @@ beginCompilationUnit(class) handleType(Map, null) handleIdentifier(foo6, fieldDeclaration) beginFieldInitializer(=) - handleRecoverableError(Message[UnexpectedToken, Unexpected token 'Map'., null, {lexeme: Map}], Map, Map) + handleRecoverableError(Message[LiteralWithClass, A map literal can't be prefixed by 'Map'., Try removing 'Map', {string: map, lexeme: Map}], Map, Map) beginTypeArguments(<) handleIdentifier(String, typeReference) handleNoTypeArguments(,) @@ -228,7 +228,7 @@ beginCompilationUnit(class) handleType(Map, null) handleIdentifier(foo7, fieldDeclaration) beginFieldInitializer(=) - handleRecoverableError(Message[UnexpectedToken, Unexpected token 'Map'., null, {lexeme: Map}], Map, Map) + handleRecoverableError(Message[LiteralWithClass, A map literal can't be prefixed by 'Map'., Try removing 'Map', {string: map, lexeme: Map}], Map, Map) handleNoTypeArguments({) beginLiteralString("a") endLiteralString(0, :) diff --git a/pkg/front_end/parser_testcases/error_recovery/issue_45251.dart.intertwined.expect b/pkg/front_end/parser_testcases/error_recovery/issue_45251.dart.intertwined.expect index 3e01156abd6..8e981b1d2cd 100644 --- a/pkg/front_end/parser_testcases/error_recovery/issue_45251.dart.intertwined.expect +++ b/pkg/front_end/parser_testcases/error_recovery/issue_45251.dart.intertwined.expect @@ -55,8 +55,8 @@ parseUnit(class) parsePrimary(=, expression) parseSendOrFunctionLiteral(=, expression) parseSend(=, expression) - reportRecoverableErrorWithToken(Map, Instance of 'Template<(Token) => Message>') - listener: handleRecoverableError(Message[UnexpectedToken, Unexpected token 'Map'., null, {lexeme: Map}], Map, Map) + reportRecoverableError(Map, Message[LiteralWithClass, A map literal can't be prefixed by 'Map'., Try removing 'Map', {string: map, lexeme: Map}]) + listener: handleRecoverableError(Message[LiteralWithClass, A map literal can't be prefixed by 'Map'., Try removing 'Map', {string: map, lexeme: Map}], Map, Map) parsePrimary(Map, expression) parseLiteralListSetMapOrFunction(Map, null) listener: beginTypeArguments(<) @@ -150,8 +150,8 @@ parseUnit(class) parsePrimary(=, expression) parseSendOrFunctionLiteral(=, expression) parseSend(=, expression) - reportRecoverableErrorWithToken(Map, Instance of 'Template<(Token) => Message>') - listener: handleRecoverableError(Message[UnexpectedToken, Unexpected token 'Map'., null, {lexeme: Map}], Map, Map) + reportRecoverableError(Map, Message[LiteralWithClass, A map literal can't be prefixed by 'Map'., Try removing 'Map', {string: map, lexeme: Map}]) + listener: handleRecoverableError(Message[LiteralWithClass, A map literal can't be prefixed by 'Map'., Try removing 'Map', {string: map, lexeme: Map}], Map, Map) parsePrimary(Map, expression) listener: handleNoTypeArguments({) parseLiteralSetOrMapSuffix(Map, null) @@ -283,8 +283,8 @@ parseUnit(class) parsePrimary(=, expression) parseSendOrFunctionLiteral(=, expression) parseSend(=, expression) - reportRecoverableErrorWithToken(Map, Instance of 'Template<(Token) => Message>') - listener: handleRecoverableError(Message[UnexpectedToken, Unexpected token 'Map'., null, {lexeme: Map}], Map, Map) + reportRecoverableError(Map, Message[LiteralWithClass, A map literal can't be prefixed by 'Map'., Try removing 'Map', {string: map, lexeme: Map}]) + listener: handleRecoverableError(Message[LiteralWithClass, A map literal can't be prefixed by 'Map'., Try removing 'Map', {string: map, lexeme: Map}], Map, Map) parsePrimary(Map, expression) parseLiteralListSetMapOrFunction(Map, null) listener: beginTypeArguments(<) @@ -348,8 +348,8 @@ parseUnit(class) parsePrimary(=, expression) parseSendOrFunctionLiteral(=, expression) parseSend(=, expression) - reportRecoverableErrorWithToken(Map, Instance of 'Template<(Token) => Message>') - listener: handleRecoverableError(Message[UnexpectedToken, Unexpected token 'Map'., null, {lexeme: Map}], Map, Map) + reportRecoverableError(Map, Message[LiteralWithClass, A map literal can't be prefixed by 'Map'., Try removing 'Map', {string: map, lexeme: Map}]) + listener: handleRecoverableError(Message[LiteralWithClass, A map literal can't be prefixed by 'Map'., Try removing 'Map', {string: map, lexeme: Map}], Map, Map) parsePrimary(Map, expression) listener: handleNoTypeArguments({) parseLiteralSetOrMapSuffix(Map, null) diff --git a/pkg/front_end/parser_testcases/error_recovery/issue_45251_const.dart.expect b/pkg/front_end/parser_testcases/error_recovery/issue_45251_const.dart.expect index 34a2a617e5d..0291006c937 100644 --- a/pkg/front_end/parser_testcases/error_recovery/issue_45251_const.dart.expect +++ b/pkg/front_end/parser_testcases/error_recovery/issue_45251_const.dart.expect @@ -1,18 +1,18 @@ Problems reported: -parser/error_recovery/issue_45251_const:3:45: Unexpected token 'Map'. +parser/error_recovery/issue_45251_const:3:45: A map literal can't be prefixed by 'Map'. final Map foo1 = const Map>{}; ^^^ -parser/error_recovery/issue_45251_const:9:45: Unexpected token 'Map'. +parser/error_recovery/issue_45251_const:9:45: A map literal can't be prefixed by 'Map'. final Map foo3 = const Map{}; ^^^ -parser/error_recovery/issue_45251_const:18:45: Unexpected token 'Map'. +parser/error_recovery/issue_45251_const:18:45: A map literal can't be prefixed by 'Map'. final Map foo6 = const Map>{"a": null}; ^^^ -parser/error_recovery/issue_45251_const:21:45: Unexpected token 'Map'. +parser/error_recovery/issue_45251_const:21:45: A map literal can't be prefixed by 'Map'. final Map foo7 = const Map{"a": null}; ^^^ @@ -45,7 +45,7 @@ beginCompilationUnit(class) handleType(Map, null) handleIdentifier(foo1, fieldDeclaration) beginFieldInitializer(=) - handleRecoverableError(Message[UnexpectedToken, Unexpected token 'Map'., null, {lexeme: Map}], Map, Map) + handleRecoverableError(Message[LiteralWithClass, A map literal can't be prefixed by 'Map'., Try removing 'Map', {string: map, lexeme: Map}], Map, Map) beginConstLiteral(<) beginTypeArguments(<) handleIdentifier(String, typeReference) @@ -114,7 +114,7 @@ beginCompilationUnit(class) handleType(Map, null) handleIdentifier(foo3, fieldDeclaration) beginFieldInitializer(=) - handleRecoverableError(Message[UnexpectedToken, Unexpected token 'Map'., null, {lexeme: Map}], Map, Map) + handleRecoverableError(Message[LiteralWithClass, A map literal can't be prefixed by 'Map'., Try removing 'Map', {string: map, lexeme: Map}], Map, Map) beginConstLiteral({) handleNoTypeArguments({) handleLiteralSetOrMap(0, {, const, }, false) @@ -205,7 +205,7 @@ beginCompilationUnit(class) handleType(Map, null) handleIdentifier(foo6, fieldDeclaration) beginFieldInitializer(=) - handleRecoverableError(Message[UnexpectedToken, Unexpected token 'Map'., null, {lexeme: Map}], Map, Map) + handleRecoverableError(Message[LiteralWithClass, A map literal can't be prefixed by 'Map'., Try removing 'Map', {string: map, lexeme: Map}], Map, Map) beginConstLiteral(<) beginTypeArguments(<) handleIdentifier(String, typeReference) @@ -244,7 +244,7 @@ beginCompilationUnit(class) handleType(Map, null) handleIdentifier(foo7, fieldDeclaration) beginFieldInitializer(=) - handleRecoverableError(Message[UnexpectedToken, Unexpected token 'Map'., null, {lexeme: Map}], Map, Map) + handleRecoverableError(Message[LiteralWithClass, A map literal can't be prefixed by 'Map'., Try removing 'Map', {string: map, lexeme: Map}], Map, Map) beginConstLiteral({) handleNoTypeArguments({) beginLiteralString("a") diff --git a/pkg/front_end/parser_testcases/error_recovery/issue_45251_const.dart.intertwined.expect b/pkg/front_end/parser_testcases/error_recovery/issue_45251_const.dart.intertwined.expect index 7637c4bd23d..3d2e81d6dd0 100644 --- a/pkg/front_end/parser_testcases/error_recovery/issue_45251_const.dart.intertwined.expect +++ b/pkg/front_end/parser_testcases/error_recovery/issue_45251_const.dart.intertwined.expect @@ -54,8 +54,8 @@ parseUnit(class) parseUnaryExpression(=, true) parsePrimary(=, expression) parseConstExpression(=) - reportRecoverableErrorWithToken(Map, Instance of 'Template<(Token) => Message>') - listener: handleRecoverableError(Message[UnexpectedToken, Unexpected token 'Map'., null, {lexeme: Map}], Map, Map) + reportRecoverableError(Map, Message[LiteralWithClass, A map literal can't be prefixed by 'Map'., Try removing 'Map', {string: map, lexeme: Map}]) + listener: handleRecoverableError(Message[LiteralWithClass, A map literal can't be prefixed by 'Map'., Try removing 'Map', {string: map, lexeme: Map}], Map, Map) listener: beginConstLiteral(<) parseLiteralListSetMapOrFunction(Map, const) listener: beginTypeArguments(<) @@ -152,8 +152,8 @@ parseUnit(class) parseUnaryExpression(=, true) parsePrimary(=, expression) parseConstExpression(=) - reportRecoverableErrorWithToken(Map, Instance of 'Template<(Token) => Message>') - listener: handleRecoverableError(Message[UnexpectedToken, Unexpected token 'Map'., null, {lexeme: Map}], Map, Map) + reportRecoverableError(Map, Message[LiteralWithClass, A map literal can't be prefixed by 'Map'., Try removing 'Map', {string: map, lexeme: Map}]) + listener: handleRecoverableError(Message[LiteralWithClass, A map literal can't be prefixed by 'Map'., Try removing 'Map', {string: map, lexeme: Map}], Map, Map) listener: beginConstLiteral({) listener: handleNoTypeArguments({) parseLiteralSetOrMapSuffix(Map, const) @@ -291,8 +291,8 @@ parseUnit(class) parseUnaryExpression(=, true) parsePrimary(=, expression) parseConstExpression(=) - reportRecoverableErrorWithToken(Map, Instance of 'Template<(Token) => Message>') - listener: handleRecoverableError(Message[UnexpectedToken, Unexpected token 'Map'., null, {lexeme: Map}], Map, Map) + reportRecoverableError(Map, Message[LiteralWithClass, A map literal can't be prefixed by 'Map'., Try removing 'Map', {string: map, lexeme: Map}]) + listener: handleRecoverableError(Message[LiteralWithClass, A map literal can't be prefixed by 'Map'., Try removing 'Map', {string: map, lexeme: Map}], Map, Map) listener: beginConstLiteral(<) parseLiteralListSetMapOrFunction(Map, const) listener: beginTypeArguments(<) @@ -356,8 +356,8 @@ parseUnit(class) parseUnaryExpression(=, true) parsePrimary(=, expression) parseConstExpression(=) - reportRecoverableErrorWithToken(Map, Instance of 'Template<(Token) => Message>') - listener: handleRecoverableError(Message[UnexpectedToken, Unexpected token 'Map'., null, {lexeme: Map}], Map, Map) + reportRecoverableError(Map, Message[LiteralWithClass, A map literal can't be prefixed by 'Map'., Try removing 'Map', {string: map, lexeme: Map}]) + listener: handleRecoverableError(Message[LiteralWithClass, A map literal can't be prefixed by 'Map'., Try removing 'Map', {string: map, lexeme: Map}], Map, Map) listener: beginConstLiteral({) listener: handleNoTypeArguments({) parseLiteralSetOrMapSuffix(Map, const) diff --git a/pkg/front_end/parser_testcases/error_recovery/issue_45251_list.dart.expect b/pkg/front_end/parser_testcases/error_recovery/issue_45251_list.dart.expect index b04432389b4..f5c21fa9b0c 100644 --- a/pkg/front_end/parser_testcases/error_recovery/issue_45251_list.dart.expect +++ b/pkg/front_end/parser_testcases/error_recovery/issue_45251_list.dart.expect @@ -1,14 +1,14 @@ Problems reported: -parser/error_recovery/issue_45251_list:3:32: Unexpected token 'List'. +parser/error_recovery/issue_45251_list:3:32: A list literal can't be prefixed by 'List'. final List foo1 = List>[]; ^^^^ -parser/error_recovery/issue_45251_list:9:32: Unexpected token 'List'. +parser/error_recovery/issue_45251_list:9:32: A list literal can't be prefixed by 'List'. final List foo3 = List[]; ^^^^ -parser/error_recovery/issue_45251_list:18:32: Unexpected token 'List'. +parser/error_recovery/issue_45251_list:18:32: A list literal can't be prefixed by 'List'. final List foo6 = List>[null]; ^^^^ @@ -38,7 +38,7 @@ beginCompilationUnit(class) handleType(List, null) handleIdentifier(foo1, fieldDeclaration) beginFieldInitializer(=) - handleRecoverableError(Message[UnexpectedToken, Unexpected token 'List'., null, {lexeme: List}], List, List) + handleRecoverableError(Message[LiteralWithClass, A list literal can't be prefixed by 'List'., Try removing 'List', {string: list, lexeme: List}], List, List) beginTypeArguments(<) handleIdentifier(List, typeReference) beginTypeArguments(<) @@ -91,7 +91,7 @@ beginCompilationUnit(class) handleType(List, null) handleIdentifier(foo3, fieldDeclaration) beginFieldInitializer(=) - handleRecoverableError(Message[UnexpectedToken, Unexpected token 'List'., null, {lexeme: List}], List, List) + handleRecoverableError(Message[LiteralWithClass, A list literal can't be prefixed by 'List'., Try removing 'List', {string: list, lexeme: List}], List, List) handleNoTypeArguments([]) handleLiteralList(0, [, null, ]) endFieldInitializer(=, ;) @@ -160,7 +160,7 @@ beginCompilationUnit(class) handleType(List, null) handleIdentifier(foo6, fieldDeclaration) beginFieldInitializer(=) - handleRecoverableError(Message[UnexpectedToken, Unexpected token 'List'., null, {lexeme: List}], List, List) + handleRecoverableError(Message[LiteralWithClass, A list literal can't be prefixed by 'List'., Try removing 'List', {string: list, lexeme: List}], List, List) beginTypeArguments(<) handleIdentifier(List, typeReference) beginTypeArguments(<) diff --git a/pkg/front_end/parser_testcases/error_recovery/issue_45251_list.dart.intertwined.expect b/pkg/front_end/parser_testcases/error_recovery/issue_45251_list.dart.intertwined.expect index 219459602d3..a0732681999 100644 --- a/pkg/front_end/parser_testcases/error_recovery/issue_45251_list.dart.intertwined.expect +++ b/pkg/front_end/parser_testcases/error_recovery/issue_45251_list.dart.intertwined.expect @@ -51,8 +51,8 @@ parseUnit(class) parsePrimary(=, expression) parseSendOrFunctionLiteral(=, expression) parseSend(=, expression) - reportRecoverableErrorWithToken(List, Instance of 'Template<(Token) => Message>') - listener: handleRecoverableError(Message[UnexpectedToken, Unexpected token 'List'., null, {lexeme: List}], List, List) + reportRecoverableError(List, Message[LiteralWithClass, A list literal can't be prefixed by 'List'., Try removing 'List', {string: list, lexeme: List}]) + listener: handleRecoverableError(Message[LiteralWithClass, A list literal can't be prefixed by 'List'., Try removing 'List', {string: list, lexeme: List}], List, List) parsePrimary(List, expression) parseLiteralListSetMapOrFunction(List, null) listener: beginTypeArguments(<) @@ -138,8 +138,8 @@ parseUnit(class) parsePrimary(=, expression) parseSendOrFunctionLiteral(=, expression) parseSend(=, expression) - reportRecoverableErrorWithToken(List, Instance of 'Template<(Token) => Message>') - listener: handleRecoverableError(Message[UnexpectedToken, Unexpected token 'List'., null, {lexeme: List}], List, List) + reportRecoverableError(List, Message[LiteralWithClass, A list literal can't be prefixed by 'List'., Try removing 'List', {string: list, lexeme: List}]) + listener: handleRecoverableError(Message[LiteralWithClass, A list literal can't be prefixed by 'List'., Try removing 'List', {string: list, lexeme: List}], List, List) parsePrimary(List, expression) listener: handleNoTypeArguments([]) parseLiteralListSuffix(List, null) @@ -259,8 +259,8 @@ parseUnit(class) parsePrimary(=, expression) parseSendOrFunctionLiteral(=, expression) parseSend(=, expression) - reportRecoverableErrorWithToken(List, Instance of 'Template<(Token) => Message>') - listener: handleRecoverableError(Message[UnexpectedToken, Unexpected token 'List'., null, {lexeme: List}], List, List) + reportRecoverableError(List, Message[LiteralWithClass, A list literal can't be prefixed by 'List'., Try removing 'List', {string: list, lexeme: List}]) + listener: handleRecoverableError(Message[LiteralWithClass, A list literal can't be prefixed by 'List'., Try removing 'List', {string: list, lexeme: List}], List, List) parsePrimary(List, expression) parseLiteralListSetMapOrFunction(List, null) listener: beginTypeArguments(<) diff --git a/pkg/front_end/parser_testcases/error_recovery/issue_45251_list_const.dart.expect b/pkg/front_end/parser_testcases/error_recovery/issue_45251_list_const.dart.expect index 9c4318d1388..0f278c9e4f2 100644 --- a/pkg/front_end/parser_testcases/error_recovery/issue_45251_list_const.dart.expect +++ b/pkg/front_end/parser_testcases/error_recovery/issue_45251_list_const.dart.expect @@ -1,18 +1,18 @@ Problems reported: -parser/error_recovery/issue_45251_list_const:3:38: Unexpected token 'List'. +parser/error_recovery/issue_45251_list_const:3:38: A list literal can't be prefixed by 'List'. final List foo1 = const List>[]; ^^^^ -parser/error_recovery/issue_45251_list_const:9:38: Unexpected token 'List'. +parser/error_recovery/issue_45251_list_const:9:38: A list literal can't be prefixed by 'List'. final List foo3 = const List[]; ^^^^ -parser/error_recovery/issue_45251_list_const:18:38: Unexpected token 'List'. +parser/error_recovery/issue_45251_list_const:18:38: A list literal can't be prefixed by 'List'. final List foo6 = const List>[null]; ^^^^ -parser/error_recovery/issue_45251_list_const:22:38: Unexpected token 'List'. +parser/error_recovery/issue_45251_list_const:22:38: A list literal can't be prefixed by 'List'. final List foo7 = const List[null]; ^^^^ @@ -42,7 +42,7 @@ beginCompilationUnit(class) handleType(List, null) handleIdentifier(foo1, fieldDeclaration) beginFieldInitializer(=) - handleRecoverableError(Message[UnexpectedToken, Unexpected token 'List'., null, {lexeme: List}], List, List) + handleRecoverableError(Message[LiteralWithClass, A list literal can't be prefixed by 'List'., Try removing 'List', {string: list, lexeme: List}], List, List) beginConstLiteral(<) beginTypeArguments(<) handleIdentifier(List, typeReference) @@ -99,7 +99,7 @@ beginCompilationUnit(class) handleType(List, null) handleIdentifier(foo3, fieldDeclaration) beginFieldInitializer(=) - handleRecoverableError(Message[UnexpectedToken, Unexpected token 'List'., null, {lexeme: List}], List, List) + handleRecoverableError(Message[LiteralWithClass, A list literal can't be prefixed by 'List'., Try removing 'List', {string: list, lexeme: List}], List, List) beginConstLiteral([]) handleNoTypeArguments([]) handleLiteralList(0, [, const, ]) @@ -178,7 +178,7 @@ beginCompilationUnit(class) handleType(List, null) handleIdentifier(foo6, fieldDeclaration) beginFieldInitializer(=) - handleRecoverableError(Message[UnexpectedToken, Unexpected token 'List'., null, {lexeme: List}], List, List) + handleRecoverableError(Message[LiteralWithClass, A list literal can't be prefixed by 'List'., Try removing 'List', {string: list, lexeme: List}], List, List) beginConstLiteral(<) beginTypeArguments(<) handleIdentifier(List, typeReference) @@ -208,7 +208,7 @@ beginCompilationUnit(class) handleType(List, null) handleIdentifier(foo7, fieldDeclaration) beginFieldInitializer(=) - handleRecoverableError(Message[UnexpectedToken, Unexpected token 'List'., null, {lexeme: List}], List, List) + handleRecoverableError(Message[LiteralWithClass, A list literal can't be prefixed by 'List'., Try removing 'List', {string: list, lexeme: List}], List, List) beginConstLiteral([) handleNoTypeArguments([) handleLiteralNull(null) diff --git a/pkg/front_end/parser_testcases/error_recovery/issue_45251_list_const.dart.intertwined.expect b/pkg/front_end/parser_testcases/error_recovery/issue_45251_list_const.dart.intertwined.expect index 310f11d0b4f..84d3ed8b9b5 100644 --- a/pkg/front_end/parser_testcases/error_recovery/issue_45251_list_const.dart.intertwined.expect +++ b/pkg/front_end/parser_testcases/error_recovery/issue_45251_list_const.dart.intertwined.expect @@ -50,8 +50,8 @@ parseUnit(class) parseUnaryExpression(=, true) parsePrimary(=, expression) parseConstExpression(=) - reportRecoverableErrorWithToken(List, Instance of 'Template<(Token) => Message>') - listener: handleRecoverableError(Message[UnexpectedToken, Unexpected token 'List'., null, {lexeme: List}], List, List) + reportRecoverableError(List, Message[LiteralWithClass, A list literal can't be prefixed by 'List'., Try removing 'List', {string: list, lexeme: List}]) + listener: handleRecoverableError(Message[LiteralWithClass, A list literal can't be prefixed by 'List'., Try removing 'List', {string: list, lexeme: List}], List, List) listener: beginConstLiteral(<) parseLiteralListSetMapOrFunction(List, const) listener: beginTypeArguments(<) @@ -140,8 +140,8 @@ parseUnit(class) parseUnaryExpression(=, true) parsePrimary(=, expression) parseConstExpression(=) - reportRecoverableErrorWithToken(List, Instance of 'Template<(Token) => Message>') - listener: handleRecoverableError(Message[UnexpectedToken, Unexpected token 'List'., null, {lexeme: List}], List, List) + reportRecoverableError(List, Message[LiteralWithClass, A list literal can't be prefixed by 'List'., Try removing 'List', {string: list, lexeme: List}]) + listener: handleRecoverableError(Message[LiteralWithClass, A list literal can't be prefixed by 'List'., Try removing 'List', {string: list, lexeme: List}], List, List) listener: beginConstLiteral([]) listener: handleNoTypeArguments([]) parseLiteralListSuffix(List, const) @@ -267,8 +267,8 @@ parseUnit(class) parseUnaryExpression(=, true) parsePrimary(=, expression) parseConstExpression(=) - reportRecoverableErrorWithToken(List, Instance of 'Template<(Token) => Message>') - listener: handleRecoverableError(Message[UnexpectedToken, Unexpected token 'List'., null, {lexeme: List}], List, List) + reportRecoverableError(List, Message[LiteralWithClass, A list literal can't be prefixed by 'List'., Try removing 'List', {string: list, lexeme: List}]) + listener: handleRecoverableError(Message[LiteralWithClass, A list literal can't be prefixed by 'List'., Try removing 'List', {string: list, lexeme: List}], List, List) listener: beginConstLiteral(<) parseLiteralListSetMapOrFunction(List, const) listener: beginTypeArguments(<) @@ -316,8 +316,8 @@ parseUnit(class) parseUnaryExpression(=, true) parsePrimary(=, expression) parseConstExpression(=) - reportRecoverableErrorWithToken(List, Instance of 'Template<(Token) => Message>') - listener: handleRecoverableError(Message[UnexpectedToken, Unexpected token 'List'., null, {lexeme: List}], List, List) + reportRecoverableError(List, Message[LiteralWithClass, A list literal can't be prefixed by 'List'., Try removing 'List', {string: list, lexeme: List}]) + listener: handleRecoverableError(Message[LiteralWithClass, A list literal can't be prefixed by 'List'., Try removing 'List', {string: list, lexeme: List}], List, List) listener: beginConstLiteral([) listener: handleNoTypeArguments([) parseLiteralListSuffix(List, const) diff --git a/pkg/front_end/parser_testcases/error_recovery/issue_45251_list_new.dart.expect b/pkg/front_end/parser_testcases/error_recovery/issue_45251_list_new.dart.expect index af78fd62315..447db690250 100644 --- a/pkg/front_end/parser_testcases/error_recovery/issue_45251_list_new.dart.expect +++ b/pkg/front_end/parser_testcases/error_recovery/issue_45251_list_new.dart.expect @@ -1,46 +1,30 @@ Problems reported: -parser/error_recovery/issue_45251_list_new:3:32: Unexpected token 'new'. +parser/error_recovery/issue_45251_list_new:3:32: A list literal can't be prefixed by 'new List'. final List foo1 = new List>[]; - ^^^ + ^^^^^^^^ -parser/error_recovery/issue_45251_list_new:3:36: Unexpected token 'List'. - final List foo1 = new List>[]; - ^^^^ - -parser/error_recovery/issue_45251_list_new:6:32: Unexpected token 'new'. +parser/error_recovery/issue_45251_list_new:6:32: A literal can't be prefixed by 'new'. final List foo2 = new >[]; ^^^ -parser/error_recovery/issue_45251_list_new:9:32: Unexpected token 'new'. +parser/error_recovery/issue_45251_list_new:9:32: A list literal can't be prefixed by 'new List'. final List foo3 = new List[]; - ^^^ + ^^^^^^^^ -parser/error_recovery/issue_45251_list_new:9:36: Unexpected token 'List'. - final List foo3 = new List[]; - ^^^^ - -parser/error_recovery/issue_45251_list_new:18:32: Unexpected token 'new'. +parser/error_recovery/issue_45251_list_new:18:32: A list literal can't be prefixed by 'new List'. final List foo6 = new List>[null]; - ^^^ + ^^^^^^^^ -parser/error_recovery/issue_45251_list_new:18:36: Unexpected token 'List'. - final List foo6 = new List>[null]; - ^^^^ - -parser/error_recovery/issue_45251_list_new:22:32: Unexpected token 'new'. +parser/error_recovery/issue_45251_list_new:22:32: A list literal can't be prefixed by 'new List'. final List foo7 = new List[null]; - ^^^ + ^^^^^^^^ -parser/error_recovery/issue_45251_list_new:22:36: Unexpected token 'List'. - final List foo7 = new List[null]; - ^^^^ - -parser/error_recovery/issue_45251_list_new:25:32: Unexpected token 'new'. +parser/error_recovery/issue_45251_list_new:25:32: A literal can't be prefixed by 'new'. final List foo8 = new >[null]; ^^^ -parser/error_recovery/issue_45251_list_new:28:32: Unexpected token 'new'. +parser/error_recovery/issue_45251_list_new:28:32: A literal can't be prefixed by 'new'. final List foo9 = new [null]; ^^^ @@ -70,8 +54,7 @@ beginCompilationUnit(class) handleType(List, null) handleIdentifier(foo1, fieldDeclaration) beginFieldInitializer(=) - handleRecoverableError(Message[UnexpectedToken, Unexpected token 'new'., null, {lexeme: new}], new, new) - handleRecoverableError(Message[UnexpectedToken, Unexpected token 'List'., null, {lexeme: List}], List, List) + handleRecoverableError(Message[LiteralWithClassAndNew, A list literal can't be prefixed by 'new List'., Try removing 'new' and 'List', {string: list, lexeme: List}], new, List) beginTypeArguments(<) handleIdentifier(List, typeReference) beginTypeArguments(<) @@ -98,7 +81,7 @@ beginCompilationUnit(class) handleType(List, null) handleIdentifier(foo2, fieldDeclaration) beginFieldInitializer(=) - handleRecoverableError(Message[UnexpectedToken, Unexpected token 'new'., null, {lexeme: new}], new, new) + handleRecoverableError(LiteralWithNew, new, new) beginTypeArguments(<) handleIdentifier(List, typeReference) beginTypeArguments(<) @@ -125,8 +108,7 @@ beginCompilationUnit(class) handleType(List, null) handleIdentifier(foo3, fieldDeclaration) beginFieldInitializer(=) - handleRecoverableError(Message[UnexpectedToken, Unexpected token 'new'., null, {lexeme: new}], new, new) - handleRecoverableError(Message[UnexpectedToken, Unexpected token 'List'., null, {lexeme: List}], List, List) + handleRecoverableError(Message[LiteralWithClassAndNew, A list literal can't be prefixed by 'new List'., Try removing 'new' and 'List', {string: list, lexeme: List}], new, List) handleNoTypeArguments([]) handleLiteralList(0, [, null, ]) endFieldInitializer(=, ;) @@ -203,8 +185,7 @@ beginCompilationUnit(class) handleType(List, null) handleIdentifier(foo6, fieldDeclaration) beginFieldInitializer(=) - handleRecoverableError(Message[UnexpectedToken, Unexpected token 'new'., null, {lexeme: new}], new, new) - handleRecoverableError(Message[UnexpectedToken, Unexpected token 'List'., null, {lexeme: List}], List, List) + handleRecoverableError(Message[LiteralWithClassAndNew, A list literal can't be prefixed by 'new List'., Try removing 'new' and 'List', {string: list, lexeme: List}], new, List) beginTypeArguments(<) handleIdentifier(List, typeReference) beginTypeArguments(<) @@ -232,8 +213,7 @@ beginCompilationUnit(class) handleType(List, null) handleIdentifier(foo7, fieldDeclaration) beginFieldInitializer(=) - handleRecoverableError(Message[UnexpectedToken, Unexpected token 'new'., null, {lexeme: new}], new, new) - handleRecoverableError(Message[UnexpectedToken, Unexpected token 'List'., null, {lexeme: List}], List, List) + handleRecoverableError(Message[LiteralWithClassAndNew, A list literal can't be prefixed by 'new List'., Try removing 'new' and 'List', {string: list, lexeme: List}], new, List) handleNoTypeArguments([) handleLiteralNull(null) handleLiteralList(1, [, null, ]) @@ -253,7 +233,7 @@ beginCompilationUnit(class) handleType(List, null) handleIdentifier(foo8, fieldDeclaration) beginFieldInitializer(=) - handleRecoverableError(Message[UnexpectedToken, Unexpected token 'new'., null, {lexeme: new}], new, new) + handleRecoverableError(LiteralWithNew, new, new) beginTypeArguments(<) handleIdentifier(List, typeReference) beginTypeArguments(<) @@ -281,7 +261,7 @@ beginCompilationUnit(class) handleType(List, null) handleIdentifier(foo9, fieldDeclaration) beginFieldInitializer(=) - handleRecoverableError(Message[UnexpectedToken, Unexpected token 'new'., null, {lexeme: new}], new, new) + handleRecoverableError(LiteralWithNew, new, new) handleNoTypeArguments([) handleLiteralNull(null) handleLiteralList(1, [, null, ]) diff --git a/pkg/front_end/parser_testcases/error_recovery/issue_45251_list_new.dart.intertwined.expect b/pkg/front_end/parser_testcases/error_recovery/issue_45251_list_new.dart.intertwined.expect index bad29ab0b53..9dd8aca7341 100644 --- a/pkg/front_end/parser_testcases/error_recovery/issue_45251_list_new.dart.intertwined.expect +++ b/pkg/front_end/parser_testcases/error_recovery/issue_45251_list_new.dart.intertwined.expect @@ -50,10 +50,7 @@ parseUnit(class) parseUnaryExpression(=, true) parsePrimary(=, expression) parseNewExpression(=) - reportRecoverableErrorWithToken(new, Instance of 'Template<(Token) => Message>') - listener: handleRecoverableError(Message[UnexpectedToken, Unexpected token 'new'., null, {lexeme: new}], new, new) - reportRecoverableErrorWithToken(List, Instance of 'Template<(Token) => Message>') - listener: handleRecoverableError(Message[UnexpectedToken, Unexpected token 'List'., null, {lexeme: List}], List, List) + listener: handleRecoverableError(Message[LiteralWithClassAndNew, A list literal can't be prefixed by 'new List'., Try removing 'new' and 'List', {string: list, lexeme: List}], new, List) parsePrimary(List, expression) parseLiteralListSetMapOrFunction(List, null) listener: beginTypeArguments(<) @@ -97,8 +94,8 @@ parseUnit(class) parseUnaryExpression(=, true) parsePrimary(=, expression) parseNewExpression(=) - reportRecoverableErrorWithToken(new, Instance of 'Template<(Token) => Message>') - listener: handleRecoverableError(Message[UnexpectedToken, Unexpected token 'new'., null, {lexeme: new}], new, new) + reportRecoverableError(new, LiteralWithNew) + listener: handleRecoverableError(LiteralWithNew, new, new) parsePrimary(new, expression) parseLiteralListSetMapOrFunction(new, null) listener: beginTypeArguments(<) @@ -142,10 +139,7 @@ parseUnit(class) parseUnaryExpression(=, true) parsePrimary(=, expression) parseNewExpression(=) - reportRecoverableErrorWithToken(new, Instance of 'Template<(Token) => Message>') - listener: handleRecoverableError(Message[UnexpectedToken, Unexpected token 'new'., null, {lexeme: new}], new, new) - reportRecoverableErrorWithToken(List, Instance of 'Template<(Token) => Message>') - listener: handleRecoverableError(Message[UnexpectedToken, Unexpected token 'List'., null, {lexeme: List}], List, List) + listener: handleRecoverableError(Message[LiteralWithClassAndNew, A list literal can't be prefixed by 'new List'., Try removing 'new' and 'List', {string: list, lexeme: List}], new, List) parsePrimary(List, expression) listener: handleNoTypeArguments([]) parseLiteralListSuffix(List, null) @@ -270,10 +264,7 @@ parseUnit(class) parseUnaryExpression(=, true) parsePrimary(=, expression) parseNewExpression(=) - reportRecoverableErrorWithToken(new, Instance of 'Template<(Token) => Message>') - listener: handleRecoverableError(Message[UnexpectedToken, Unexpected token 'new'., null, {lexeme: new}], new, new) - reportRecoverableErrorWithToken(List, Instance of 'Template<(Token) => Message>') - listener: handleRecoverableError(Message[UnexpectedToken, Unexpected token 'List'., null, {lexeme: List}], List, List) + listener: handleRecoverableError(Message[LiteralWithClassAndNew, A list literal can't be prefixed by 'new List'., Try removing 'new' and 'List', {string: list, lexeme: List}], new, List) parsePrimary(List, expression) parseLiteralListSetMapOrFunction(List, null) listener: beginTypeArguments(<) @@ -320,10 +311,7 @@ parseUnit(class) parseUnaryExpression(=, true) parsePrimary(=, expression) parseNewExpression(=) - reportRecoverableErrorWithToken(new, Instance of 'Template<(Token) => Message>') - listener: handleRecoverableError(Message[UnexpectedToken, Unexpected token 'new'., null, {lexeme: new}], new, new) - reportRecoverableErrorWithToken(List, Instance of 'Template<(Token) => Message>') - listener: handleRecoverableError(Message[UnexpectedToken, Unexpected token 'List'., null, {lexeme: List}], List, List) + listener: handleRecoverableError(Message[LiteralWithClassAndNew, A list literal can't be prefixed by 'new List'., Try removing 'new' and 'List', {string: list, lexeme: List}], new, List) parsePrimary(List, expression) listener: handleNoTypeArguments([) parseLiteralListSuffix(List, null) @@ -361,8 +349,8 @@ parseUnit(class) parseUnaryExpression(=, true) parsePrimary(=, expression) parseNewExpression(=) - reportRecoverableErrorWithToken(new, Instance of 'Template<(Token) => Message>') - listener: handleRecoverableError(Message[UnexpectedToken, Unexpected token 'new'., null, {lexeme: new}], new, new) + reportRecoverableError(new, LiteralWithNew) + listener: handleRecoverableError(LiteralWithNew, new, new) parsePrimary(new, expression) parseLiteralListSetMapOrFunction(new, null) listener: beginTypeArguments(<) @@ -409,8 +397,8 @@ parseUnit(class) parseUnaryExpression(=, true) parsePrimary(=, expression) parseNewExpression(=) - reportRecoverableErrorWithToken(new, Instance of 'Template<(Token) => Message>') - listener: handleRecoverableError(Message[UnexpectedToken, Unexpected token 'new'., null, {lexeme: new}], new, new) + reportRecoverableError(new, LiteralWithNew) + listener: handleRecoverableError(LiteralWithNew, new, new) parsePrimary(new, expression) listener: handleNoTypeArguments([) parseLiteralListSuffix(new, null) diff --git a/pkg/front_end/parser_testcases/error_recovery/issue_45251_new.dart.expect b/pkg/front_end/parser_testcases/error_recovery/issue_45251_new.dart.expect index 7854a53db11..c1b095d5b13 100644 --- a/pkg/front_end/parser_testcases/error_recovery/issue_45251_new.dart.expect +++ b/pkg/front_end/parser_testcases/error_recovery/issue_45251_new.dart.expect @@ -1,46 +1,30 @@ Problems reported: -parser/error_recovery/issue_45251_new:3:39: Unexpected token 'new'. +parser/error_recovery/issue_45251_new:3:39: A map literal can't be prefixed by 'new Map'. final Map foo1 = new Map>{}; - ^^^ + ^^^^^^^ -parser/error_recovery/issue_45251_new:3:43: Unexpected token 'Map'. - final Map foo1 = new Map>{}; - ^^^ - -parser/error_recovery/issue_45251_new:6:39: Unexpected token 'new'. +parser/error_recovery/issue_45251_new:6:39: A literal can't be prefixed by 'new'. final Map foo2 = new >{}; ^^^ -parser/error_recovery/issue_45251_new:9:39: Unexpected token 'new'. +parser/error_recovery/issue_45251_new:9:39: A map literal can't be prefixed by 'new Map'. final Map foo3 = new Map{}; - ^^^ + ^^^^^^^ -parser/error_recovery/issue_45251_new:9:43: Unexpected token 'Map'. - final Map foo3 = new Map{}; - ^^^ - -parser/error_recovery/issue_45251_new:18:39: Unexpected token 'new'. +parser/error_recovery/issue_45251_new:18:39: A map literal can't be prefixed by 'new Map'. final Map foo6 = new Map>{"a": null}; - ^^^ + ^^^^^^^ -parser/error_recovery/issue_45251_new:18:43: Unexpected token 'Map'. - final Map foo6 = new Map>{"a": null}; - ^^^ - -parser/error_recovery/issue_45251_new:21:39: Unexpected token 'new'. +parser/error_recovery/issue_45251_new:21:39: A map literal can't be prefixed by 'new Map'. final Map foo7 = new Map{"a": null}; - ^^^ + ^^^^^^^ -parser/error_recovery/issue_45251_new:21:43: Unexpected token 'Map'. - final Map foo7 = new Map{"a": null}; - ^^^ - -parser/error_recovery/issue_45251_new:24:39: Unexpected token 'new'. +parser/error_recovery/issue_45251_new:24:39: A literal can't be prefixed by 'new'. final Map foo8 = new >{"a": null}; ^^^ -parser/error_recovery/issue_45251_new:27:39: Unexpected token 'new'. +parser/error_recovery/issue_45251_new:27:39: A literal can't be prefixed by 'new'. final Map foo9 = new {"a": null}; ^^^ @@ -73,8 +57,7 @@ beginCompilationUnit(class) handleType(Map, null) handleIdentifier(foo1, fieldDeclaration) beginFieldInitializer(=) - handleRecoverableError(Message[UnexpectedToken, Unexpected token 'new'., null, {lexeme: new}], new, new) - handleRecoverableError(Message[UnexpectedToken, Unexpected token 'Map'., null, {lexeme: Map}], Map, Map) + handleRecoverableError(Message[LiteralWithClassAndNew, A map literal can't be prefixed by 'new Map'., Try removing 'new' and 'Map', {string: map, lexeme: Map}], new, Map) beginTypeArguments(<) handleIdentifier(String, typeReference) handleNoTypeArguments(,) @@ -107,7 +90,7 @@ beginCompilationUnit(class) handleType(Map, null) handleIdentifier(foo2, fieldDeclaration) beginFieldInitializer(=) - handleRecoverableError(Message[UnexpectedToken, Unexpected token 'new'., null, {lexeme: new}], new, new) + handleRecoverableError(LiteralWithNew, new, new) beginTypeArguments(<) handleIdentifier(String, typeReference) handleNoTypeArguments(,) @@ -140,8 +123,7 @@ beginCompilationUnit(class) handleType(Map, null) handleIdentifier(foo3, fieldDeclaration) beginFieldInitializer(=) - handleRecoverableError(Message[UnexpectedToken, Unexpected token 'new'., null, {lexeme: new}], new, new) - handleRecoverableError(Message[UnexpectedToken, Unexpected token 'Map'., null, {lexeme: Map}], Map, Map) + handleRecoverableError(Message[LiteralWithClassAndNew, A map literal can't be prefixed by 'new Map'., Try removing 'new' and 'Map', {string: map, lexeme: Map}], new, Map) handleNoTypeArguments({) handleLiteralSetOrMap(0, {, null, }, false) endFieldInitializer(=, ;) @@ -230,8 +212,7 @@ beginCompilationUnit(class) handleType(Map, null) handleIdentifier(foo6, fieldDeclaration) beginFieldInitializer(=) - handleRecoverableError(Message[UnexpectedToken, Unexpected token 'new'., null, {lexeme: new}], new, new) - handleRecoverableError(Message[UnexpectedToken, Unexpected token 'Map'., null, {lexeme: Map}], Map, Map) + handleRecoverableError(Message[LiteralWithClassAndNew, A map literal can't be prefixed by 'new Map'., Try removing 'new' and 'Map', {string: map, lexeme: Map}], new, Map) beginTypeArguments(<) handleIdentifier(String, typeReference) handleNoTypeArguments(,) @@ -268,8 +249,7 @@ beginCompilationUnit(class) handleType(Map, null) handleIdentifier(foo7, fieldDeclaration) beginFieldInitializer(=) - handleRecoverableError(Message[UnexpectedToken, Unexpected token 'new'., null, {lexeme: new}], new, new) - handleRecoverableError(Message[UnexpectedToken, Unexpected token 'Map'., null, {lexeme: Map}], Map, Map) + handleRecoverableError(Message[LiteralWithClassAndNew, A map literal can't be prefixed by 'new Map'., Try removing 'new' and 'Map', {string: map, lexeme: Map}], new, Map) handleNoTypeArguments({) beginLiteralString("a") endLiteralString(0, :) @@ -295,7 +275,7 @@ beginCompilationUnit(class) handleType(Map, null) handleIdentifier(foo8, fieldDeclaration) beginFieldInitializer(=) - handleRecoverableError(Message[UnexpectedToken, Unexpected token 'new'., null, {lexeme: new}], new, new) + handleRecoverableError(LiteralWithNew, new, new) beginTypeArguments(<) handleIdentifier(String, typeReference) handleNoTypeArguments(,) @@ -332,7 +312,7 @@ beginCompilationUnit(class) handleType(Map, null) handleIdentifier(foo9, fieldDeclaration) beginFieldInitializer(=) - handleRecoverableError(Message[UnexpectedToken, Unexpected token 'new'., null, {lexeme: new}], new, new) + handleRecoverableError(LiteralWithNew, new, new) handleNoTypeArguments({) beginLiteralString("a") endLiteralString(0, :) diff --git a/pkg/front_end/parser_testcases/error_recovery/issue_45251_new.dart.intertwined.expect b/pkg/front_end/parser_testcases/error_recovery/issue_45251_new.dart.intertwined.expect index b4849dbcb4c..d3039be2a37 100644 --- a/pkg/front_end/parser_testcases/error_recovery/issue_45251_new.dart.intertwined.expect +++ b/pkg/front_end/parser_testcases/error_recovery/issue_45251_new.dart.intertwined.expect @@ -54,10 +54,7 @@ parseUnit(class) parseUnaryExpression(=, true) parsePrimary(=, expression) parseNewExpression(=) - reportRecoverableErrorWithToken(new, Instance of 'Template<(Token) => Message>') - listener: handleRecoverableError(Message[UnexpectedToken, Unexpected token 'new'., null, {lexeme: new}], new, new) - reportRecoverableErrorWithToken(Map, Instance of 'Template<(Token) => Message>') - listener: handleRecoverableError(Message[UnexpectedToken, Unexpected token 'Map'., null, {lexeme: Map}], Map, Map) + listener: handleRecoverableError(Message[LiteralWithClassAndNew, A map literal can't be prefixed by 'new Map'., Try removing 'new' and 'Map', {string: map, lexeme: Map}], new, Map) parsePrimary(Map, expression) parseLiteralListSetMapOrFunction(Map, null) listener: beginTypeArguments(<) @@ -105,8 +102,8 @@ parseUnit(class) parseUnaryExpression(=, true) parsePrimary(=, expression) parseNewExpression(=) - reportRecoverableErrorWithToken(new, Instance of 'Template<(Token) => Message>') - listener: handleRecoverableError(Message[UnexpectedToken, Unexpected token 'new'., null, {lexeme: new}], new, new) + reportRecoverableError(new, LiteralWithNew) + listener: handleRecoverableError(LiteralWithNew, new, new) parsePrimary(new, expression) parseLiteralListSetMapOrFunction(new, null) listener: beginTypeArguments(<) @@ -154,10 +151,7 @@ parseUnit(class) parseUnaryExpression(=, true) parsePrimary(=, expression) parseNewExpression(=) - reportRecoverableErrorWithToken(new, Instance of 'Template<(Token) => Message>') - listener: handleRecoverableError(Message[UnexpectedToken, Unexpected token 'new'., null, {lexeme: new}], new, new) - reportRecoverableErrorWithToken(Map, Instance of 'Template<(Token) => Message>') - listener: handleRecoverableError(Message[UnexpectedToken, Unexpected token 'Map'., null, {lexeme: Map}], Map, Map) + listener: handleRecoverableError(Message[LiteralWithClassAndNew, A map literal can't be prefixed by 'new Map'., Try removing 'new' and 'Map', {string: map, lexeme: Map}], new, Map) parsePrimary(Map, expression) listener: handleNoTypeArguments({) parseLiteralSetOrMapSuffix(Map, null) @@ -294,10 +288,7 @@ parseUnit(class) parseUnaryExpression(=, true) parsePrimary(=, expression) parseNewExpression(=) - reportRecoverableErrorWithToken(new, Instance of 'Template<(Token) => Message>') - listener: handleRecoverableError(Message[UnexpectedToken, Unexpected token 'new'., null, {lexeme: new}], new, new) - reportRecoverableErrorWithToken(Map, Instance of 'Template<(Token) => Message>') - listener: handleRecoverableError(Message[UnexpectedToken, Unexpected token 'Map'., null, {lexeme: Map}], Map, Map) + listener: handleRecoverableError(Message[LiteralWithClassAndNew, A map literal can't be prefixed by 'new Map'., Try removing 'new' and 'Map', {string: map, lexeme: Map}], new, Map) parsePrimary(Map, expression) parseLiteralListSetMapOrFunction(Map, null) listener: beginTypeArguments(<) @@ -360,10 +351,7 @@ parseUnit(class) parseUnaryExpression(=, true) parsePrimary(=, expression) parseNewExpression(=) - reportRecoverableErrorWithToken(new, Instance of 'Template<(Token) => Message>') - listener: handleRecoverableError(Message[UnexpectedToken, Unexpected token 'new'., null, {lexeme: new}], new, new) - reportRecoverableErrorWithToken(Map, Instance of 'Template<(Token) => Message>') - listener: handleRecoverableError(Message[UnexpectedToken, Unexpected token 'Map'., null, {lexeme: Map}], Map, Map) + listener: handleRecoverableError(Message[LiteralWithClassAndNew, A map literal can't be prefixed by 'new Map'., Try removing 'new' and 'Map', {string: map, lexeme: Map}], new, Map) parsePrimary(Map, expression) listener: handleNoTypeArguments({) parseLiteralSetOrMapSuffix(Map, null) @@ -414,8 +402,8 @@ parseUnit(class) parseUnaryExpression(=, true) parsePrimary(=, expression) parseNewExpression(=) - reportRecoverableErrorWithToken(new, Instance of 'Template<(Token) => Message>') - listener: handleRecoverableError(Message[UnexpectedToken, Unexpected token 'new'., null, {lexeme: new}], new, new) + reportRecoverableError(new, LiteralWithNew) + listener: handleRecoverableError(LiteralWithNew, new, new) parsePrimary(new, expression) parseLiteralListSetMapOrFunction(new, null) listener: beginTypeArguments(<) @@ -478,8 +466,8 @@ parseUnit(class) parseUnaryExpression(=, true) parsePrimary(=, expression) parseNewExpression(=) - reportRecoverableErrorWithToken(new, Instance of 'Template<(Token) => Message>') - listener: handleRecoverableError(Message[UnexpectedToken, Unexpected token 'new'., null, {lexeme: new}], new, new) + reportRecoverableError(new, LiteralWithNew) + listener: handleRecoverableError(LiteralWithNew, new, new) parsePrimary(new, expression) listener: handleNoTypeArguments({) parseLiteralSetOrMapSuffix(new, null) diff --git a/pkg/front_end/parser_testcases/error_recovery/issue_45251_set.dart.expect b/pkg/front_end/parser_testcases/error_recovery/issue_45251_set.dart.expect index d8f4e8933b1..e1d57cafa3b 100644 --- a/pkg/front_end/parser_testcases/error_recovery/issue_45251_set.dart.expect +++ b/pkg/front_end/parser_testcases/error_recovery/issue_45251_set.dart.expect @@ -1,18 +1,18 @@ Problems reported: -parser/error_recovery/issue_45251_set:3:31: Unexpected token 'Set'. +parser/error_recovery/issue_45251_set:3:31: A set literal can't be prefixed by 'Set'. final Set foo1 = Set>{}; ^^^ -parser/error_recovery/issue_45251_set:9:31: Unexpected token 'Set'. +parser/error_recovery/issue_45251_set:9:31: A set literal can't be prefixed by 'Set'. final Set foo3 = Set{}; ^^^ -parser/error_recovery/issue_45251_set:18:31: Unexpected token 'Set'. +parser/error_recovery/issue_45251_set:18:31: A set literal can't be prefixed by 'Set'. final Set foo6 = Set>{null}; ^^^ -parser/error_recovery/issue_45251_set:21:31: Unexpected token 'Set'. +parser/error_recovery/issue_45251_set:21:31: A set literal can't be prefixed by 'Set'. final Set foo7 = Set{null}; ^^^ @@ -42,7 +42,7 @@ beginCompilationUnit(class) handleType(Set, null) handleIdentifier(foo1, fieldDeclaration) beginFieldInitializer(=) - handleRecoverableError(Message[UnexpectedToken, Unexpected token 'Set'., null, {lexeme: Set}], Set, Set) + handleRecoverableError(Message[LiteralWithClass, A set literal can't be prefixed by 'Set'., Try removing 'Set', {string: set, lexeme: Set}], Set, Set) beginTypeArguments(<) handleIdentifier(List, typeReference) beginTypeArguments(<) @@ -95,7 +95,7 @@ beginCompilationUnit(class) handleType(Set, null) handleIdentifier(foo3, fieldDeclaration) beginFieldInitializer(=) - handleRecoverableError(Message[UnexpectedToken, Unexpected token 'Set'., null, {lexeme: Set}], Set, Set) + handleRecoverableError(Message[LiteralWithClass, A set literal can't be prefixed by 'Set'., Try removing 'Set', {string: set, lexeme: Set}], Set, Set) handleNoTypeArguments({) handleLiteralSetOrMap(0, {, null, }, false) endFieldInitializer(=, ;) @@ -164,7 +164,7 @@ beginCompilationUnit(class) handleType(Set, null) handleIdentifier(foo6, fieldDeclaration) beginFieldInitializer(=) - handleRecoverableError(Message[UnexpectedToken, Unexpected token 'Set'., null, {lexeme: Set}], Set, Set) + handleRecoverableError(Message[LiteralWithClass, A set literal can't be prefixed by 'Set'., Try removing 'Set', {string: set, lexeme: Set}], Set, Set) beginTypeArguments(<) handleIdentifier(List, typeReference) beginTypeArguments(<) @@ -192,7 +192,7 @@ beginCompilationUnit(class) handleType(Set, null) handleIdentifier(foo7, fieldDeclaration) beginFieldInitializer(=) - handleRecoverableError(Message[UnexpectedToken, Unexpected token 'Set'., null, {lexeme: Set}], Set, Set) + handleRecoverableError(Message[LiteralWithClass, A set literal can't be prefixed by 'Set'., Try removing 'Set', {string: set, lexeme: Set}], Set, Set) handleNoTypeArguments({) handleLiteralNull(null) handleLiteralSetOrMap(1, {, null, }, true) diff --git a/pkg/front_end/parser_testcases/error_recovery/issue_45251_set.dart.intertwined.expect b/pkg/front_end/parser_testcases/error_recovery/issue_45251_set.dart.intertwined.expect index aa44787166d..9fad6f63e80 100644 --- a/pkg/front_end/parser_testcases/error_recovery/issue_45251_set.dart.intertwined.expect +++ b/pkg/front_end/parser_testcases/error_recovery/issue_45251_set.dart.intertwined.expect @@ -51,8 +51,8 @@ parseUnit(class) parsePrimary(=, expression) parseSendOrFunctionLiteral(=, expression) parseSend(=, expression) - reportRecoverableErrorWithToken(Set, Instance of 'Template<(Token) => Message>') - listener: handleRecoverableError(Message[UnexpectedToken, Unexpected token 'Set'., null, {lexeme: Set}], Set, Set) + reportRecoverableError(Set, Message[LiteralWithClass, A set literal can't be prefixed by 'Set'., Try removing 'Set', {string: set, lexeme: Set}]) + listener: handleRecoverableError(Message[LiteralWithClass, A set literal can't be prefixed by 'Set'., Try removing 'Set', {string: set, lexeme: Set}], Set, Set) parsePrimary(Set, expression) parseLiteralListSetMapOrFunction(Set, null) listener: beginTypeArguments(<) @@ -132,8 +132,8 @@ parseUnit(class) parsePrimary(=, expression) parseSendOrFunctionLiteral(=, expression) parseSend(=, expression) - reportRecoverableErrorWithToken(Set, Instance of 'Template<(Token) => Message>') - listener: handleRecoverableError(Message[UnexpectedToken, Unexpected token 'Set'., null, {lexeme: Set}], Set, Set) + reportRecoverableError(Set, Message[LiteralWithClass, A set literal can't be prefixed by 'Set'., Try removing 'Set', {string: set, lexeme: Set}]) + listener: handleRecoverableError(Message[LiteralWithClass, A set literal can't be prefixed by 'Set'., Try removing 'Set', {string: set, lexeme: Set}], Set, Set) parsePrimary(Set, expression) listener: handleNoTypeArguments({) parseLiteralSetOrMapSuffix(Set, null) @@ -250,8 +250,8 @@ parseUnit(class) parsePrimary(=, expression) parseSendOrFunctionLiteral(=, expression) parseSend(=, expression) - reportRecoverableErrorWithToken(Set, Instance of 'Template<(Token) => Message>') - listener: handleRecoverableError(Message[UnexpectedToken, Unexpected token 'Set'., null, {lexeme: Set}], Set, Set) + reportRecoverableError(Set, Message[LiteralWithClass, A set literal can't be prefixed by 'Set'., Try removing 'Set', {string: set, lexeme: Set}]) + listener: handleRecoverableError(Message[LiteralWithClass, A set literal can't be prefixed by 'Set'., Try removing 'Set', {string: set, lexeme: Set}], Set, Set) parsePrimary(Set, expression) parseLiteralListSetMapOrFunction(Set, null) listener: beginTypeArguments(<) @@ -299,8 +299,8 @@ parseUnit(class) parsePrimary(=, expression) parseSendOrFunctionLiteral(=, expression) parseSend(=, expression) - reportRecoverableErrorWithToken(Set, Instance of 'Template<(Token) => Message>') - listener: handleRecoverableError(Message[UnexpectedToken, Unexpected token 'Set'., null, {lexeme: Set}], Set, Set) + reportRecoverableError(Set, Message[LiteralWithClass, A set literal can't be prefixed by 'Set'., Try removing 'Set', {string: set, lexeme: Set}]) + listener: handleRecoverableError(Message[LiteralWithClass, A set literal can't be prefixed by 'Set'., Try removing 'Set', {string: set, lexeme: Set}], Set, Set) parsePrimary(Set, expression) listener: handleNoTypeArguments({) parseLiteralSetOrMapSuffix(Set, null) diff --git a/pkg/front_end/parser_testcases/error_recovery/issue_45251_set_const.dart.expect b/pkg/front_end/parser_testcases/error_recovery/issue_45251_set_const.dart.expect index 4d44965cbfb..7d01b7d50a7 100644 --- a/pkg/front_end/parser_testcases/error_recovery/issue_45251_set_const.dart.expect +++ b/pkg/front_end/parser_testcases/error_recovery/issue_45251_set_const.dart.expect @@ -1,18 +1,18 @@ Problems reported: -parser/error_recovery/issue_45251_set_const:3:37: Unexpected token 'Set'. +parser/error_recovery/issue_45251_set_const:3:37: A set literal can't be prefixed by 'Set'. final Set foo1 = const Set>{}; ^^^ -parser/error_recovery/issue_45251_set_const:9:37: Unexpected token 'Set'. +parser/error_recovery/issue_45251_set_const:9:37: A set literal can't be prefixed by 'Set'. final Set foo3 = const Set{}; ^^^ -parser/error_recovery/issue_45251_set_const:18:37: Unexpected token 'Set'. +parser/error_recovery/issue_45251_set_const:18:37: A set literal can't be prefixed by 'Set'. final Set foo6 = const Set>{null}; ^^^ -parser/error_recovery/issue_45251_set_const:21:37: Unexpected token 'Set'. +parser/error_recovery/issue_45251_set_const:21:37: A set literal can't be prefixed by 'Set'. final Set foo7 = const Set{null}; ^^^ @@ -42,7 +42,7 @@ beginCompilationUnit(class) handleType(Set, null) handleIdentifier(foo1, fieldDeclaration) beginFieldInitializer(=) - handleRecoverableError(Message[UnexpectedToken, Unexpected token 'Set'., null, {lexeme: Set}], Set, Set) + handleRecoverableError(Message[LiteralWithClass, A set literal can't be prefixed by 'Set'., Try removing 'Set', {string: set, lexeme: Set}], Set, Set) beginConstLiteral(<) beginTypeArguments(<) handleIdentifier(List, typeReference) @@ -99,7 +99,7 @@ beginCompilationUnit(class) handleType(Set, null) handleIdentifier(foo3, fieldDeclaration) beginFieldInitializer(=) - handleRecoverableError(Message[UnexpectedToken, Unexpected token 'Set'., null, {lexeme: Set}], Set, Set) + handleRecoverableError(Message[LiteralWithClass, A set literal can't be prefixed by 'Set'., Try removing 'Set', {string: set, lexeme: Set}], Set, Set) beginConstLiteral({) handleNoTypeArguments({) handleLiteralSetOrMap(0, {, const, }, false) @@ -178,7 +178,7 @@ beginCompilationUnit(class) handleType(Set, null) handleIdentifier(foo6, fieldDeclaration) beginFieldInitializer(=) - handleRecoverableError(Message[UnexpectedToken, Unexpected token 'Set'., null, {lexeme: Set}], Set, Set) + handleRecoverableError(Message[LiteralWithClass, A set literal can't be prefixed by 'Set'., Try removing 'Set', {string: set, lexeme: Set}], Set, Set) beginConstLiteral(<) beginTypeArguments(<) handleIdentifier(List, typeReference) @@ -208,7 +208,7 @@ beginCompilationUnit(class) handleType(Set, null) handleIdentifier(foo7, fieldDeclaration) beginFieldInitializer(=) - handleRecoverableError(Message[UnexpectedToken, Unexpected token 'Set'., null, {lexeme: Set}], Set, Set) + handleRecoverableError(Message[LiteralWithClass, A set literal can't be prefixed by 'Set'., Try removing 'Set', {string: set, lexeme: Set}], Set, Set) beginConstLiteral({) handleNoTypeArguments({) handleLiteralNull(null) diff --git a/pkg/front_end/parser_testcases/error_recovery/issue_45251_set_const.dart.intertwined.expect b/pkg/front_end/parser_testcases/error_recovery/issue_45251_set_const.dart.intertwined.expect index 8239dcba9f2..7f9a6a58f99 100644 --- a/pkg/front_end/parser_testcases/error_recovery/issue_45251_set_const.dart.intertwined.expect +++ b/pkg/front_end/parser_testcases/error_recovery/issue_45251_set_const.dart.intertwined.expect @@ -50,8 +50,8 @@ parseUnit(class) parseUnaryExpression(=, true) parsePrimary(=, expression) parseConstExpression(=) - reportRecoverableErrorWithToken(Set, Instance of 'Template<(Token) => Message>') - listener: handleRecoverableError(Message[UnexpectedToken, Unexpected token 'Set'., null, {lexeme: Set}], Set, Set) + reportRecoverableError(Set, Message[LiteralWithClass, A set literal can't be prefixed by 'Set'., Try removing 'Set', {string: set, lexeme: Set}]) + listener: handleRecoverableError(Message[LiteralWithClass, A set literal can't be prefixed by 'Set'., Try removing 'Set', {string: set, lexeme: Set}], Set, Set) listener: beginConstLiteral(<) parseLiteralListSetMapOrFunction(Set, const) listener: beginTypeArguments(<) @@ -134,8 +134,8 @@ parseUnit(class) parseUnaryExpression(=, true) parsePrimary(=, expression) parseConstExpression(=) - reportRecoverableErrorWithToken(Set, Instance of 'Template<(Token) => Message>') - listener: handleRecoverableError(Message[UnexpectedToken, Unexpected token 'Set'., null, {lexeme: Set}], Set, Set) + reportRecoverableError(Set, Message[LiteralWithClass, A set literal can't be prefixed by 'Set'., Try removing 'Set', {string: set, lexeme: Set}]) + listener: handleRecoverableError(Message[LiteralWithClass, A set literal can't be prefixed by 'Set'., Try removing 'Set', {string: set, lexeme: Set}], Set, Set) listener: beginConstLiteral({) listener: handleNoTypeArguments({) parseLiteralSetOrMapSuffix(Set, const) @@ -258,8 +258,8 @@ parseUnit(class) parseUnaryExpression(=, true) parsePrimary(=, expression) parseConstExpression(=) - reportRecoverableErrorWithToken(Set, Instance of 'Template<(Token) => Message>') - listener: handleRecoverableError(Message[UnexpectedToken, Unexpected token 'Set'., null, {lexeme: Set}], Set, Set) + reportRecoverableError(Set, Message[LiteralWithClass, A set literal can't be prefixed by 'Set'., Try removing 'Set', {string: set, lexeme: Set}]) + listener: handleRecoverableError(Message[LiteralWithClass, A set literal can't be prefixed by 'Set'., Try removing 'Set', {string: set, lexeme: Set}], Set, Set) listener: beginConstLiteral(<) parseLiteralListSetMapOrFunction(Set, const) listener: beginTypeArguments(<) @@ -307,8 +307,8 @@ parseUnit(class) parseUnaryExpression(=, true) parsePrimary(=, expression) parseConstExpression(=) - reportRecoverableErrorWithToken(Set, Instance of 'Template<(Token) => Message>') - listener: handleRecoverableError(Message[UnexpectedToken, Unexpected token 'Set'., null, {lexeme: Set}], Set, Set) + reportRecoverableError(Set, Message[LiteralWithClass, A set literal can't be prefixed by 'Set'., Try removing 'Set', {string: set, lexeme: Set}]) + listener: handleRecoverableError(Message[LiteralWithClass, A set literal can't be prefixed by 'Set'., Try removing 'Set', {string: set, lexeme: Set}], Set, Set) listener: beginConstLiteral({) listener: handleNoTypeArguments({) parseLiteralSetOrMapSuffix(Set, const) diff --git a/pkg/front_end/parser_testcases/error_recovery/issue_45251_set_new.dart.expect b/pkg/front_end/parser_testcases/error_recovery/issue_45251_set_new.dart.expect index aa57003e8f9..1df0d1bba71 100644 --- a/pkg/front_end/parser_testcases/error_recovery/issue_45251_set_new.dart.expect +++ b/pkg/front_end/parser_testcases/error_recovery/issue_45251_set_new.dart.expect @@ -1,46 +1,30 @@ Problems reported: -parser/error_recovery/issue_45251_set_new:3:31: Unexpected token 'new'. +parser/error_recovery/issue_45251_set_new:3:31: A set literal can't be prefixed by 'new Set'. final Set foo1 = new Set>{}; - ^^^ + ^^^^^^^ -parser/error_recovery/issue_45251_set_new:3:35: Unexpected token 'Set'. - final Set foo1 = new Set>{}; - ^^^ - -parser/error_recovery/issue_45251_set_new:6:31: Unexpected token 'new'. +parser/error_recovery/issue_45251_set_new:6:31: A literal can't be prefixed by 'new'. final Set foo2 = new >{}; ^^^ -parser/error_recovery/issue_45251_set_new:9:31: Unexpected token 'new'. +parser/error_recovery/issue_45251_set_new:9:31: A set literal can't be prefixed by 'new Set'. final Set foo3 = new Set{}; - ^^^ + ^^^^^^^ -parser/error_recovery/issue_45251_set_new:9:35: Unexpected token 'Set'. - final Set foo3 = new Set{}; - ^^^ - -parser/error_recovery/issue_45251_set_new:18:31: Unexpected token 'new'. +parser/error_recovery/issue_45251_set_new:18:31: A set literal can't be prefixed by 'new Set'. final Set foo6 = new Set>{null}; - ^^^ + ^^^^^^^ -parser/error_recovery/issue_45251_set_new:18:35: Unexpected token 'Set'. - final Set foo6 = new Set>{null}; - ^^^ - -parser/error_recovery/issue_45251_set_new:21:31: Unexpected token 'new'. +parser/error_recovery/issue_45251_set_new:21:31: A set literal can't be prefixed by 'new Set'. final Set foo7 = new Set{null}; - ^^^ + ^^^^^^^ -parser/error_recovery/issue_45251_set_new:21:35: Unexpected token 'Set'. - final Set foo7 = new Set{null}; - ^^^ - -parser/error_recovery/issue_45251_set_new:24:31: Unexpected token 'new'. +parser/error_recovery/issue_45251_set_new:24:31: A literal can't be prefixed by 'new'. final Set foo8 = new >{null}; ^^^ -parser/error_recovery/issue_45251_set_new:27:31: Unexpected token 'new'. +parser/error_recovery/issue_45251_set_new:27:31: A literal can't be prefixed by 'new'. final Set foo9 = new {null}; ^^^ @@ -70,8 +54,7 @@ beginCompilationUnit(class) handleType(Set, null) handleIdentifier(foo1, fieldDeclaration) beginFieldInitializer(=) - handleRecoverableError(Message[UnexpectedToken, Unexpected token 'new'., null, {lexeme: new}], new, new) - handleRecoverableError(Message[UnexpectedToken, Unexpected token 'Set'., null, {lexeme: Set}], Set, Set) + handleRecoverableError(Message[LiteralWithClassAndNew, A set literal can't be prefixed by 'new Set'., Try removing 'new' and 'Set', {string: set, lexeme: Set}], new, Set) beginTypeArguments(<) handleIdentifier(List, typeReference) beginTypeArguments(<) @@ -98,7 +81,7 @@ beginCompilationUnit(class) handleType(Set, null) handleIdentifier(foo2, fieldDeclaration) beginFieldInitializer(=) - handleRecoverableError(Message[UnexpectedToken, Unexpected token 'new'., null, {lexeme: new}], new, new) + handleRecoverableError(LiteralWithNew, new, new) beginTypeArguments(<) handleIdentifier(List, typeReference) beginTypeArguments(<) @@ -125,8 +108,7 @@ beginCompilationUnit(class) handleType(Set, null) handleIdentifier(foo3, fieldDeclaration) beginFieldInitializer(=) - handleRecoverableError(Message[UnexpectedToken, Unexpected token 'new'., null, {lexeme: new}], new, new) - handleRecoverableError(Message[UnexpectedToken, Unexpected token 'Set'., null, {lexeme: Set}], Set, Set) + handleRecoverableError(Message[LiteralWithClassAndNew, A set literal can't be prefixed by 'new Set'., Try removing 'new' and 'Set', {string: set, lexeme: Set}], new, Set) handleNoTypeArguments({) handleLiteralSetOrMap(0, {, null, }, false) endFieldInitializer(=, ;) @@ -203,8 +185,7 @@ beginCompilationUnit(class) handleType(Set, null) handleIdentifier(foo6, fieldDeclaration) beginFieldInitializer(=) - handleRecoverableError(Message[UnexpectedToken, Unexpected token 'new'., null, {lexeme: new}], new, new) - handleRecoverableError(Message[UnexpectedToken, Unexpected token 'Set'., null, {lexeme: Set}], Set, Set) + handleRecoverableError(Message[LiteralWithClassAndNew, A set literal can't be prefixed by 'new Set'., Try removing 'new' and 'Set', {string: set, lexeme: Set}], new, Set) beginTypeArguments(<) handleIdentifier(List, typeReference) beginTypeArguments(<) @@ -232,8 +213,7 @@ beginCompilationUnit(class) handleType(Set, null) handleIdentifier(foo7, fieldDeclaration) beginFieldInitializer(=) - handleRecoverableError(Message[UnexpectedToken, Unexpected token 'new'., null, {lexeme: new}], new, new) - handleRecoverableError(Message[UnexpectedToken, Unexpected token 'Set'., null, {lexeme: Set}], Set, Set) + handleRecoverableError(Message[LiteralWithClassAndNew, A set literal can't be prefixed by 'new Set'., Try removing 'new' and 'Set', {string: set, lexeme: Set}], new, Set) handleNoTypeArguments({) handleLiteralNull(null) handleLiteralSetOrMap(1, {, null, }, true) @@ -253,7 +233,7 @@ beginCompilationUnit(class) handleType(Set, null) handleIdentifier(foo8, fieldDeclaration) beginFieldInitializer(=) - handleRecoverableError(Message[UnexpectedToken, Unexpected token 'new'., null, {lexeme: new}], new, new) + handleRecoverableError(LiteralWithNew, new, new) beginTypeArguments(<) handleIdentifier(List, typeReference) beginTypeArguments(<) @@ -281,7 +261,7 @@ beginCompilationUnit(class) handleType(Set, null) handleIdentifier(foo9, fieldDeclaration) beginFieldInitializer(=) - handleRecoverableError(Message[UnexpectedToken, Unexpected token 'new'., null, {lexeme: new}], new, new) + handleRecoverableError(LiteralWithNew, new, new) handleNoTypeArguments({) handleLiteralNull(null) handleLiteralSetOrMap(1, {, null, }, true) diff --git a/pkg/front_end/parser_testcases/error_recovery/issue_45251_set_new.dart.intertwined.expect b/pkg/front_end/parser_testcases/error_recovery/issue_45251_set_new.dart.intertwined.expect index 2eb284f9788..49f104311be 100644 --- a/pkg/front_end/parser_testcases/error_recovery/issue_45251_set_new.dart.intertwined.expect +++ b/pkg/front_end/parser_testcases/error_recovery/issue_45251_set_new.dart.intertwined.expect @@ -50,10 +50,7 @@ parseUnit(class) parseUnaryExpression(=, true) parsePrimary(=, expression) parseNewExpression(=) - reportRecoverableErrorWithToken(new, Instance of 'Template<(Token) => Message>') - listener: handleRecoverableError(Message[UnexpectedToken, Unexpected token 'new'., null, {lexeme: new}], new, new) - reportRecoverableErrorWithToken(Set, Instance of 'Template<(Token) => Message>') - listener: handleRecoverableError(Message[UnexpectedToken, Unexpected token 'Set'., null, {lexeme: Set}], Set, Set) + listener: handleRecoverableError(Message[LiteralWithClassAndNew, A set literal can't be prefixed by 'new Set'., Try removing 'new' and 'Set', {string: set, lexeme: Set}], new, Set) parsePrimary(Set, expression) parseLiteralListSetMapOrFunction(Set, null) listener: beginTypeArguments(<) @@ -94,8 +91,8 @@ parseUnit(class) parseUnaryExpression(=, true) parsePrimary(=, expression) parseNewExpression(=) - reportRecoverableErrorWithToken(new, Instance of 'Template<(Token) => Message>') - listener: handleRecoverableError(Message[UnexpectedToken, Unexpected token 'new'., null, {lexeme: new}], new, new) + reportRecoverableError(new, LiteralWithNew) + listener: handleRecoverableError(LiteralWithNew, new, new) parsePrimary(new, expression) parseLiteralListSetMapOrFunction(new, null) listener: beginTypeArguments(<) @@ -136,10 +133,7 @@ parseUnit(class) parseUnaryExpression(=, true) parsePrimary(=, expression) parseNewExpression(=) - reportRecoverableErrorWithToken(new, Instance of 'Template<(Token) => Message>') - listener: handleRecoverableError(Message[UnexpectedToken, Unexpected token 'new'., null, {lexeme: new}], new, new) - reportRecoverableErrorWithToken(Set, Instance of 'Template<(Token) => Message>') - listener: handleRecoverableError(Message[UnexpectedToken, Unexpected token 'Set'., null, {lexeme: Set}], Set, Set) + listener: handleRecoverableError(Message[LiteralWithClassAndNew, A set literal can't be prefixed by 'new Set'., Try removing 'new' and 'Set', {string: set, lexeme: Set}], new, Set) parsePrimary(Set, expression) listener: handleNoTypeArguments({) parseLiteralSetOrMapSuffix(Set, null) @@ -261,10 +255,7 @@ parseUnit(class) parseUnaryExpression(=, true) parsePrimary(=, expression) parseNewExpression(=) - reportRecoverableErrorWithToken(new, Instance of 'Template<(Token) => Message>') - listener: handleRecoverableError(Message[UnexpectedToken, Unexpected token 'new'., null, {lexeme: new}], new, new) - reportRecoverableErrorWithToken(Set, Instance of 'Template<(Token) => Message>') - listener: handleRecoverableError(Message[UnexpectedToken, Unexpected token 'Set'., null, {lexeme: Set}], Set, Set) + listener: handleRecoverableError(Message[LiteralWithClassAndNew, A set literal can't be prefixed by 'new Set'., Try removing 'new' and 'Set', {string: set, lexeme: Set}], new, Set) parsePrimary(Set, expression) parseLiteralListSetMapOrFunction(Set, null) listener: beginTypeArguments(<) @@ -311,10 +302,7 @@ parseUnit(class) parseUnaryExpression(=, true) parsePrimary(=, expression) parseNewExpression(=) - reportRecoverableErrorWithToken(new, Instance of 'Template<(Token) => Message>') - listener: handleRecoverableError(Message[UnexpectedToken, Unexpected token 'new'., null, {lexeme: new}], new, new) - reportRecoverableErrorWithToken(Set, Instance of 'Template<(Token) => Message>') - listener: handleRecoverableError(Message[UnexpectedToken, Unexpected token 'Set'., null, {lexeme: Set}], Set, Set) + listener: handleRecoverableError(Message[LiteralWithClassAndNew, A set literal can't be prefixed by 'new Set'., Try removing 'new' and 'Set', {string: set, lexeme: Set}], new, Set) parsePrimary(Set, expression) listener: handleNoTypeArguments({) parseLiteralSetOrMapSuffix(Set, null) @@ -352,8 +340,8 @@ parseUnit(class) parseUnaryExpression(=, true) parsePrimary(=, expression) parseNewExpression(=) - reportRecoverableErrorWithToken(new, Instance of 'Template<(Token) => Message>') - listener: handleRecoverableError(Message[UnexpectedToken, Unexpected token 'new'., null, {lexeme: new}], new, new) + reportRecoverableError(new, LiteralWithNew) + listener: handleRecoverableError(LiteralWithNew, new, new) parsePrimary(new, expression) parseLiteralListSetMapOrFunction(new, null) listener: beginTypeArguments(<) @@ -400,8 +388,8 @@ parseUnit(class) parseUnaryExpression(=, true) parsePrimary(=, expression) parseNewExpression(=) - reportRecoverableErrorWithToken(new, Instance of 'Template<(Token) => Message>') - listener: handleRecoverableError(Message[UnexpectedToken, Unexpected token 'new'., null, {lexeme: new}], new, new) + reportRecoverableError(new, LiteralWithNew) + listener: handleRecoverableError(LiteralWithNew, new, new) parsePrimary(new, expression) listener: handleNoTypeArguments({) parseLiteralSetOrMapSuffix(new, null) diff --git a/pkg/front_end/testcases/regress/issue_31155.dart.weak.expect b/pkg/front_end/testcases/regress/issue_31155.dart.weak.expect index 0acdfa9684d..2f83d695c09 100644 --- a/pkg/front_end/testcases/regress/issue_31155.dart.weak.expect +++ b/pkg/front_end/testcases/regress/issue_31155.dart.weak.expect @@ -2,7 +2,8 @@ library; // // Problems in library: // -// pkg/front_end/testcases/regress/issue_31155.dart:11:11: Error: Unexpected token 'Map'. +// pkg/front_end/testcases/regress/issue_31155.dart:11:11: Error: A map literal can't be prefixed by 'Map'. +// Try removing 'Map' // var f = Map {}; // ^^^ // diff --git a/pkg/front_end/testcases/regress/issue_31155.dart.weak.outline.expect b/pkg/front_end/testcases/regress/issue_31155.dart.weak.outline.expect index 45d6de2c71d..2a3e5efc60e 100644 --- a/pkg/front_end/testcases/regress/issue_31155.dart.weak.outline.expect +++ b/pkg/front_end/testcases/regress/issue_31155.dart.weak.outline.expect @@ -2,7 +2,8 @@ library; // // Problems in library: // -// pkg/front_end/testcases/regress/issue_31155.dart:11:11: Error: Unexpected token 'Map'. +// pkg/front_end/testcases/regress/issue_31155.dart:11:11: Error: A map literal can't be prefixed by 'Map'. +// Try removing 'Map' // var f = Map {}; // ^^^ // diff --git a/pkg/front_end/testcases/regress/issue_31155.dart.weak.transformed.expect b/pkg/front_end/testcases/regress/issue_31155.dart.weak.transformed.expect index 0acdfa9684d..2f83d695c09 100644 --- a/pkg/front_end/testcases/regress/issue_31155.dart.weak.transformed.expect +++ b/pkg/front_end/testcases/regress/issue_31155.dart.weak.transformed.expect @@ -2,7 +2,8 @@ library; // // Problems in library: // -// pkg/front_end/testcases/regress/issue_31155.dart:11:11: Error: Unexpected token 'Map'. +// pkg/front_end/testcases/regress/issue_31155.dart:11:11: Error: A map literal can't be prefixed by 'Map'. +// Try removing 'Map' // var f = Map {}; // ^^^ // diff --git a/tests/language/list/literal5_test.dart b/tests/language/list/literal5_test.dart index 5226bb7a209..ea27f04f376 100644 --- a/tests/language/list/literal5_test.dart +++ b/tests/language/list/literal5_test.dart @@ -6,10 +6,7 @@ main() { new List[1, 2]; -//^^^ -// [analyzer] SYNTACTIC_ERROR.UNEXPECTED_TOKEN -// [cfe] Unexpected token 'new'. - // ^^^^ - // [analyzer] SYNTACTIC_ERROR.UNEXPECTED_TOKEN - // [cfe] Unexpected token 'List'. +//^^^^^^^^ +// [analyzer] SYNTACTIC_ERROR.LITERAL_WITH_CLASS_AND_NEW +// [cfe] A list literal can't be prefixed by 'new List'. } diff --git a/tests/language/map/literal13_test.dart b/tests/language/map/literal13_test.dart index 5ebbbc9ec90..1ab622b23fb 100644 --- a/tests/language/map/literal13_test.dart +++ b/tests/language/map/literal13_test.dart @@ -6,12 +6,9 @@ main() { var map = new Map{ "a": 1, "b": 2, "c": 3 }; - // ^^^ - // [analyzer] SYNTACTIC_ERROR.UNEXPECTED_TOKEN - // [cfe] Unexpected token 'new'. - // ^^^ - // [analyzer] SYNTACTIC_ERROR.UNEXPECTED_TOKEN - // [cfe] Unexpected token 'Map'. + // ^^^^^^^ + // [analyzer] SYNTACTIC_ERROR.LITERAL_WITH_CLASS_AND_NEW + // [cfe] A map literal can't be prefixed by 'new Map'. // ^^^^^^ // [analyzer] COMPILE_TIME_ERROR.MAP_ENTRY_NOT_IN_MAP // ^ diff --git a/tests/language_2/list/literal5_test.dart b/tests/language_2/list/literal5_test.dart index 5226bb7a209..ea27f04f376 100644 --- a/tests/language_2/list/literal5_test.dart +++ b/tests/language_2/list/literal5_test.dart @@ -6,10 +6,7 @@ main() { new List[1, 2]; -//^^^ -// [analyzer] SYNTACTIC_ERROR.UNEXPECTED_TOKEN -// [cfe] Unexpected token 'new'. - // ^^^^ - // [analyzer] SYNTACTIC_ERROR.UNEXPECTED_TOKEN - // [cfe] Unexpected token 'List'. +//^^^^^^^^ +// [analyzer] SYNTACTIC_ERROR.LITERAL_WITH_CLASS_AND_NEW +// [cfe] A list literal can't be prefixed by 'new List'. } diff --git a/tests/language_2/map/literal13_test.dart b/tests/language_2/map/literal13_test.dart index 5ebbbc9ec90..1ab622b23fb 100644 --- a/tests/language_2/map/literal13_test.dart +++ b/tests/language_2/map/literal13_test.dart @@ -6,12 +6,9 @@ main() { var map = new Map{ "a": 1, "b": 2, "c": 3 }; - // ^^^ - // [analyzer] SYNTACTIC_ERROR.UNEXPECTED_TOKEN - // [cfe] Unexpected token 'new'. - // ^^^ - // [analyzer] SYNTACTIC_ERROR.UNEXPECTED_TOKEN - // [cfe] Unexpected token 'Map'. + // ^^^^^^^ + // [analyzer] SYNTACTIC_ERROR.LITERAL_WITH_CLASS_AND_NEW + // [cfe] A map literal can't be prefixed by 'new Map'. // ^^^^^^ // [analyzer] COMPILE_TIME_ERROR.MAP_ENTRY_NOT_IN_MAP // ^