| Index: pkg/analyzer/lib/src/summary/summarize_const_expr.dart
|
| diff --git a/pkg/analyzer/lib/src/summary/summarize_const_expr.dart b/pkg/analyzer/lib/src/summary/summarize_const_expr.dart
|
| index faaa1f4a387303fedca0ef737929c86363cd2e08..1671448a987071f434306abd72cd837cd77d904b 100644
|
| --- a/pkg/analyzer/lib/src/summary/summarize_const_expr.dart
|
| +++ b/pkg/analyzer/lib/src/summary/summarize_const_expr.dart
|
| @@ -85,7 +85,7 @@ abstract class AbstractConstExprSerializer {
|
| void serialize(Expression expr) {
|
| try {
|
| _serialize(expr);
|
| - } on StateError {
|
| + } on StateError catch (e, st) {
|
| isInvalid = true;
|
| }
|
| }
|
| @@ -107,6 +107,12 @@ abstract class AbstractConstExprSerializer {
|
| */
|
| EntityRefBuilder serializeIdentifier(Identifier identifier);
|
|
|
| + /**
|
| + * Return [EntityRefBuilder] that corresponds to the given [expr], which
|
| + * must be a sequence of identifiers.
|
| + */
|
| + EntityRefBuilder serializeIdentifierSequence(Expression expr);
|
| +
|
| void serializeInstanceCreation(
|
| EntityRefBuilder constructor, ArgumentList argumentList) {
|
| List<Expression> arguments = argumentList.arguments;
|
| @@ -130,11 +136,6 @@ abstract class AbstractConstExprSerializer {
|
| }
|
|
|
| /**
|
| - * Return [EntityRefBuilder] that corresponds to the given [access].
|
| - */
|
| - EntityRefBuilder serializePropertyAccess(PropertyAccess access);
|
| -
|
| - /**
|
| * Return [EntityRefBuilder] that corresponds to the given [type].
|
| */
|
| EntityRefBuilder serializeType(TypeName type);
|
| @@ -237,14 +238,7 @@ abstract class AbstractConstExprSerializer {
|
| } else if (expr is PrefixExpression) {
|
| _serializePrefixExpression(expr);
|
| } else if (expr is PropertyAccess) {
|
| - if (expr.target is! PrefixedIdentifier &&
|
| - expr.propertyName.name == 'length') {
|
| - _serialize(expr.target);
|
| - operations.add(UnlinkedConstOperation.length);
|
| - } else {
|
| - references.add(serializePropertyAccess(expr));
|
| - operations.add(UnlinkedConstOperation.pushReference);
|
| - }
|
| + _serializePropertyAccess(expr);
|
| } else if (expr is ParenthesizedExpression) {
|
| _serialize(expr.expression);
|
| } else {
|
| @@ -342,6 +336,18 @@ abstract class AbstractConstExprSerializer {
|
| }
|
| }
|
|
|
| + void _serializePropertyAccess(PropertyAccess expr) {
|
| + if (_isIdentifierSequence(expr)) {
|
| + EntityRefBuilder ref = serializeIdentifierSequence(expr);
|
| + references.add(ref);
|
| + operations.add(UnlinkedConstOperation.pushReference);
|
| + } else {
|
| + _serialize(expr.target);
|
| + strings.add(expr.propertyName.name);
|
| + operations.add(UnlinkedConstOperation.extractProperty);
|
| + }
|
| + }
|
| +
|
| void _serializeString(StringLiteral expr) {
|
| if (expr is AdjacentStrings) {
|
| if (expr.strings.every((string) => string is SimpleStringLiteral)) {
|
| @@ -369,4 +375,23 @@ abstract class AbstractConstExprSerializer {
|
| ints.add(interpolation.elements.length);
|
| }
|
| }
|
| +
|
| + /**
|
| + * Return `true` if the given [expr] is a sequence of identifiers.
|
| + */
|
| + static bool _isIdentifierSequence(Expression expr) {
|
| + while (expr != null) {
|
| + if (expr is SimpleIdentifier) {
|
| + return true;
|
| + }
|
| + if (expr is PrefixedIdentifier) {
|
| + expr = (expr as PrefixedIdentifier).prefix;
|
| + } else if (expr is PropertyAccess) {
|
| + expr = (expr as PropertyAccess).target;
|
| + } else {
|
| + return false;
|
| + }
|
| + }
|
| + return false;
|
| + }
|
| }
|
|
|