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

Unified Diff: pkg/analyzer/lib/src/summary/resynthesize.dart

Issue 1668983002: Resynthesize 'String.length' getter references in constants. (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
« no previous file with comments | « no previous file | pkg/analyzer/test/src/summary/resynthesize_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/summary/resynthesize.dart
diff --git a/pkg/analyzer/lib/src/summary/resynthesize.dart b/pkg/analyzer/lib/src/summary/resynthesize.dart
index 107d34f603b928c7c5d549306874ca303e2920ac..205628f5fdb8cb4f9f3c385e1f62ba88dcff5258 100644
--- a/pkg/analyzer/lib/src/summary/resynthesize.dart
+++ b/pkg/analyzer/lib/src/summary/resynthesize.dart
@@ -426,8 +426,12 @@ class _ConstExprBuilder {
_pushInstanceCreation();
break;
case UnlinkedConstOperation.length:
- return AstFactory.nullLiteral();
-// throw new StateError('Unsupported constant operation $operation');
+ Expression target = _pop();
+ SimpleIdentifier property = AstFactory.identifier3('length');
+ property.staticElement =
+ resynthesizer._buildStringLengthPropertyAccessorElement();
+ _push(AstFactory.propertyAccess(target, property));
+ break;
}
}
return stack.single;
@@ -1621,6 +1625,9 @@ class _LibraryResynthesizer {
assert(location.components.length == 4);
element = new MethodElementHandle(summaryResynthesizer, location);
break;
+ case ReferenceKind.length:
+ element = _buildStringLengthPropertyAccessorElement();
+ break;
default:
// This is an element that doesn't (yet) need to be referred to
// directly, so don't bother populating an element for it.
@@ -1689,6 +1696,15 @@ class _LibraryResynthesizer {
}
/**
+ * Return the new handle of the `String.length` getter element.
+ */
+ PropertyAccessorElementHandle _buildStringLengthPropertyAccessorElement() =>
+ new PropertyAccessorElementHandle(
+ summaryResynthesizer,
+ new ElementLocationImpl.con3(
+ <String>['dart:core', 'dart:core', 'String', 'length?']));
+
+ /**
* If the given [kind] is a top-level or class member property accessor, and
* the given [name] does not end with `=`, i.e. does not denote a setter,
* return the getter identifier by appending `?`.
« no previous file with comments | « no previous file | pkg/analyzer/test/src/summary/resynthesize_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698