Chromium Code Reviews| Index: pkg/analyzer/test/generated/parser_test.dart |
| diff --git a/pkg/analyzer/test/generated/parser_test.dart b/pkg/analyzer/test/generated/parser_test.dart |
| index 2b33566942c71c9950b5b72b37a47b0aa014fa28..0cf01e149a651950df7afcd8a1b4e2a27d5dc3d0 100644 |
| --- a/pkg/analyzer/test/generated/parser_test.dart |
| +++ b/pkg/analyzer/test/generated/parser_test.dart |
| @@ -1518,6 +1518,50 @@ class Foo { |
| reason: 'parser recovers what it can'); |
| } |
| + void test_method_invalidTypeParameterExtends() { |
| + // Regression test for https://github.com/dart-lang/sdk/issues/25739. |
| + |
| + // TODO(jmesserly): ideally we'd be better at parser recovery here. |
| + enableGenericMethods = true; |
| + MethodDeclaration method = parse3( |
| + "parseClassMember", |
| + <Object>["C"], |
| + "f<E>(E extends num p);", |
| + [ |
| + ParserErrorCode.MISSING_IDENTIFIER, // `extends` is a keyword |
| + ParserErrorCode.EXPECTED_TOKEN, // comma |
| + ParserErrorCode.EXPECTED_TOKEN, // close paren |
| + ParserErrorCode.MISSING_FUNCTION_BODY |
| + ]); |
| + expect(method.parameters.toString(), '(E, extends)', |
| + reason: 'parser recovers what it can'); |
| + } |
| + |
| + |
| + void test_method_invalidTypeParameterExtendsComment() { |
| + // Regression test for https://github.com/dart-lang/sdk/issues/25739. |
| + |
| + // TODO(jmesserly): ideally we'd be better at parser recovery here. |
| + // Also, this behavior is slightly different from how we would parse a |
| + // normal generic method, because we "discover" the comment at a different |
| + // point in the parser. This has a slight effect on the AST that results |
| + // from error recovery. |
| + enableGenericMethodComments = true; |
| + MethodDeclaration method = parse3( |
| + "parseClassMember", |
| + <Object>["C"], |
| + "f/*<E>*/(dynamic/*=E extends num*/p);", |
|
Brian Wilkerson
2016/02/12 17:56:55
When we're inserting the tokens from the comment,
|
| + [ |
| + ParserErrorCode.MISSING_IDENTIFIER, // `extends` is a keyword |
| + ParserErrorCode.EXPECTED_TOKEN, // comma |
| + ParserErrorCode.MISSING_IDENTIFIER, // `extends` is a keyword |
| + ParserErrorCode.EXPECTED_TOKEN, // close paren |
| + ParserErrorCode.MISSING_FUNCTION_BODY |
| + ]); |
| + expect(method.parameters.toString(), '(E extends, extends)', |
|
Brian Wilkerson
2016/02/12 17:56:55
I don't think this actually tests that the comment
|
| + reason: 'parser recovers what it can'); |
| + } |
| + |
| void test_missingAssignableSelector_identifiersAssigned() { |
| parseExpression("x.y = y;"); |
| } |