Chromium Code Reviews| 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; |