Always parse 'x.y' as a prefixed identifier.

R=brianwilkerson@google.com
BUG=

Review-Url: https://codereview.chromium.org/2722153003 .
This commit is contained in:
Konstantin Shcheglov 2017-03-01 10:42:51 -08:00
parent d921f94367
commit cc7c61124b
3 changed files with 11 additions and 10 deletions

View file

@ -6357,11 +6357,6 @@ class Parser {
Expression selectorExpression = parseAssignableSelector(
expression, isOptional || (expression is PrefixedIdentifier));
if (identical(selectorExpression, expression)) {
if (!isOptional && (expression is PrefixedIdentifier)) {
PrefixedIdentifier identifier = expression as PrefixedIdentifier;
expression = astFactory.propertyAccess(
identifier.prefix, identifier.period, identifier.identifier);
}
return expression;
}
expression = selectorExpression;

View file

@ -434,6 +434,12 @@ class ExpressionParserTest_Fasta extends FastaParserTestCase
.test_parseAssignableExpression_identifier_args_dot_typeParameterComments();
}
@override
@failingTest
void test_parseAssignableExpression_identifier_dot() {
super.test_parseAssignableExpression_identifier_dot();
}
@override
@failingTest
void test_parseAssignableExpression_identifier_question_dot() {

View file

@ -4180,11 +4180,11 @@ abstract class ExpressionParserTestMixin implements AbstractParserTestCase {
Expression expression = parseAssignableExpression('x.y', false);
expect(expression, isNotNull);
assertNoErrors();
var propertyAccess = expression as PropertyAccess;
expect(propertyAccess.target, isNotNull);
expect(propertyAccess.operator, isNotNull);
expect(propertyAccess.operator.type, TokenType.PERIOD);
expect(propertyAccess.propertyName, isNotNull);
var identifier = expression as PrefixedIdentifier;
expect(identifier.prefix.name, 'x');
expect(identifier.period, isNotNull);
expect(identifier.period.type, TokenType.PERIOD);
expect(identifier.identifier.name, 'y');
}
void test_parseAssignableExpression_identifier_index() {