Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(251)

Unified Diff: pkg/analyzer/test/generated/parser_test.dart

Issue 1686173002: fix #25739, incorrectly expanding a generic comment multiple times (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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;");
}
« pkg/analyzer/lib/src/generated/parser.dart ('K') | « pkg/analyzer/lib/src/generated/parser.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698