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

Unified Diff: pkg/analyzer/lib/src/generated/incremental_resolver.dart

Issue 1682333003: Remove only local variables/functions from the cache. (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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/generated/incremental_resolver.dart
diff --git a/pkg/analyzer/lib/src/generated/incremental_resolver.dart b/pkg/analyzer/lib/src/generated/incremental_resolver.dart
index b19b4b1d06a1ecbe2be76d1046a5f8b933b6a55b..640a58f0042b1927792579ce9eb76f3232d94959 100644
--- a/pkg/analyzer/lib/src/generated/incremental_resolver.dart
+++ b/pkg/analyzer/lib/src/generated/incremental_resolver.dart
@@ -2049,9 +2049,9 @@ class _DeclarationMismatchException {}
/**
* Adjusts the location of each Element that moved.
*
- * Since operator== and hashCode of an Element are based
- * on the element location, we also need to remove each
- * moved element from the cache to avoid a memory leak.
+ * Since `==` and `hashCode` of a local variable or function Element are based
+ * on the element name offsets, we also need to remove these elements from the
+ * cache to avoid a memory leak. TODO(scheglov) fix and remove this
*/
class _ElementOffsetUpdater extends GeneralizingElementVisitor {
final int updateOffset;
@@ -2065,7 +2065,13 @@ class _ElementOffsetUpdater extends GeneralizingElementVisitor {
// name offset
int nameOffset = element.nameOffset;
if (nameOffset > updateOffset) {
- cache.remove(element);
+ // TODO(scheglov) make sure that we don't put local variables
+ // and functions into the cache at all.
+ if (element is LocalVariableElement ||
skybrian 2016/02/13 18:39:22 This check is missing DefaultParameterElementImpl
+ element is FunctionElement &&
+ element.enclosingElement is ExecutableElement) {
+ cache.remove(element);
+ }
(element as ElementImpl).nameOffset = nameOffset + updateDelta;
if (element is ConstVariableElement) {
ConstVariableElement constVariable = element as ConstVariableElement;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698