Skip to content

Commit

Permalink
When DefaultFormalParameter, don't use ParameterKind.REQUIRED.
Browse files Browse the repository at this point in the history
It's a compilation error, but we still want to be consisten.

R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org/2477183002 .
  • Loading branch information
scheglov committed Nov 7, 2016
1 parent 9723a28 commit ed172dd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pkg/analyzer/lib/src/generated/parser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2799,6 +2799,7 @@ class Parser {
if (kind == ParameterKind.REQUIRED) {
_reportErrorForNode(
ParserErrorCode.POSITIONAL_PARAMETER_OUTSIDE_GROUP, parameter);
kind = ParameterKind.POSITIONAL;
}
return new DefaultFormalParameter(
parameter, kind, separator, defaultValue);
Expand All @@ -2812,6 +2813,7 @@ class Parser {
} else if (kind == ParameterKind.REQUIRED) {
_reportErrorForNode(
ParserErrorCode.NAMED_PARAMETER_OUTSIDE_GROUP, parameter);
kind = ParameterKind.NAMED;
}
return new DefaultFormalParameter(
parameter, kind, separator, defaultValue);
Expand Down
4 changes: 4 additions & 0 deletions pkg/analyzer/test/generated/parser_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2166,6 +2166,8 @@ class Foo {
expectNotNullIfNoErrors(list);
listener
.assertErrorsWithCodes([ParserErrorCode.NAMED_PARAMETER_OUTSIDE_GROUP]);
expect(list.parameters[0].kind, ParameterKind.REQUIRED);
expect(list.parameters[1].kind, ParameterKind.NAMED);
}

void test_nonConstructorFactory_field() {
Expand Down Expand Up @@ -2292,6 +2294,8 @@ class Foo {
expectNotNullIfNoErrors(list);
listener.assertErrorsWithCodes(
[ParserErrorCode.POSITIONAL_PARAMETER_OUTSIDE_GROUP]);
expect(list.parameters[0].kind, ParameterKind.REQUIRED);
expect(list.parameters[1].kind, ParameterKind.POSITIONAL);
}

void test_redirectingConstructorWithBody_named() {
Expand Down

0 comments on commit ed172dd

Please sign in to comment.