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

Issue 2480783003: Avoid writing to the same parts of the element model in two tasks. (Closed)

Created:
4 years, 1 month ago by Paul Berry
Modified:
4 years, 1 month ago
CC:
reviews_dartlang.org
Target Ref:
refs/heads/master
Visibility:
Public.

Description

Avoid writing to the same parts of the element model in two tasks. Previous to this change, ResolveUnitTypeNamesTask would set types to `dynamic` if there was no explicit type in the source code, and InferInstanceMembersInUnitTask would overwrite those types with inferred types. This caused a problem if the result of ResolveUnitTypeNamesTask got flushed due to memory pressure, but the result of InferInstanceMembersInUnitTask did not. In that case, the task model would come back at a later time and re-run ResolveUnitTypeNamesTask, causing the inferred types to be set back to `dynamic`. But it would not re-run InferInstanceMembersInUnitTask. As a result, the inferred type would be lost. This manifested as a sporadic failure to inferred types in analysis server. Annoyingly, edits to the file(s) involved would frequently cover up the problem (temporarily) since they would invalidate the cache entries, forcing the task model to re-run both tasks. This CL fixes the problem by adding _declaredType and _declaredReturnType fields to the element model; ResolveUnitTypeNamesTask writes to those. InferInstanceMembersInUnitTask continues to write to _type and _returnType, as it always has. When a type or return type is requested from the element model, the getter consults _type (or _returnType) first; only if it is null does it fall back to _declaredType (or _declaredReturnType). This gives us the behavior we need (inferred types override the implied "dynamic" type stored by ResolveUnitTypeNamesTask), but since the two tasks are now writing to different fields in the element model, it is now safe to re-run ResolveUnitTypeNamesTask--it will no longer overwrite the inferred types. Fixes #27482. R=scheglov@google.com Committed: https://github.com/dart-lang/sdk/commit/f9c55af608019c5e69f4a19ffab6b6f54e4ac9c7

Patch Set 1 #

Unified diffs Side-by-side diffs Delta from patch set Stats (+196 lines, -38 lines) Patch
M pkg/analyzer/lib/src/dart/element/element.dart View 9 chunks +37 lines, -17 lines 0 comments Download
M pkg/analyzer/lib/src/generated/resolver.dart View 11 chunks +12 lines, -12 lines 0 comments Download
M pkg/analyzer/test/src/context/context_test.dart View 4 chunks +147 lines, -9 lines 0 comments Download

Messages

Total messages: 6 (2 generated)
Paul Berry
4 years, 1 month ago (2016-11-04 20:25:45 UTC) #2
scheglov
LGTM!
4 years, 1 month ago (2016-11-04 20:33:41 UTC) #3
Paul Berry
Committed patchset #1 (id:1) manually as f9c55af608019c5e69f4a19ffab6b6f54e4ac9c7 (presubmit successful).
4 years, 1 month ago (2016-11-04 23:44:33 UTC) #5
Brian Wilkerson
4 years, 1 month ago (2016-11-06 17:38:17 UTC) #6
Message was sent while issue was closed.
lgtm

Powered by Google App Engine
This is Rietveld 408576698