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

Unified Diff: pkg/analyzer/lib/src/dart/element/type.dart

Issue 2136703002: Flush InterfaceTypeImpl cached memebers when ClassElement.version is different. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 5 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 | « pkg/analyzer/lib/src/dart/element/element.dart ('k') | pkg/analyzer/lib/src/summary/link.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/dart/element/type.dart
diff --git a/pkg/analyzer/lib/src/dart/element/type.dart b/pkg/analyzer/lib/src/dart/element/type.dart
index 22a247ab3bfa0a509ded516f0a674157829c7ce6..df190085af056ab3edface93eaaf5be38d19a1cd 100644
--- a/pkg/analyzer/lib/src/dart/element/type.dart
+++ b/pkg/analyzer/lib/src/dart/element/type.dart
@@ -1176,6 +1176,11 @@ class InterfaceTypeImpl extends TypeImpl implements InterfaceType {
final List<FunctionTypeAliasElement> prunedTypedefs;
/**
+ * The version of [element] for which members are cached.
+ */
+ int _versionOfCachedMembers = null;
+
+ /**
* Cached [ConstructorElement]s - members or raw elements.
*/
List<ConstructorElement> _constructors;
@@ -1223,6 +1228,7 @@ class InterfaceTypeImpl extends TypeImpl implements InterfaceType {
@override
List<PropertyAccessorElement> get accessors {
+ _flushCachedMembersIfStale();
if (_accessors == null) {
List<PropertyAccessorElement> accessors = element.accessors;
List<PropertyAccessorElement> members =
@@ -1237,6 +1243,7 @@ class InterfaceTypeImpl extends TypeImpl implements InterfaceType {
@override
List<ConstructorElement> get constructors {
+ _flushCachedMembersIfStale();
if (_constructors == null) {
List<ConstructorElement> constructors = element.constructors;
List<ConstructorElement> members =
@@ -1331,6 +1338,7 @@ class InterfaceTypeImpl extends TypeImpl implements InterfaceType {
@override
List<MethodElement> get methods {
+ _flushCachedMembersIfStale();
if (_methods == null) {
List<MethodElement> methods = element.methods;
List<MethodElement> members = new List<MethodElement>(methods.length);
@@ -1891,6 +1899,23 @@ class InterfaceTypeImpl extends TypeImpl implements InterfaceType {
instantiate(argumentTypes);
/**
+ * Flush cache members if the version of [element] for which members are
+ * cached and the current version of the [element].
+ */
+ void _flushCachedMembersIfStale() {
+ ClassElement element = this.element;
+ if (element is ClassElementImpl) {
+ int currentVersion = element.version;
+ if (_versionOfCachedMembers != currentVersion) {
+ _constructors = null;
+ _accessors = null;
+ _methods = null;
+ }
+ _versionOfCachedMembers = currentVersion;
+ }
+ }
+
+ /**
* Starting from this type, search its class hierarchy for types of the form
* Future<R>, and return a list of the resulting R's.
*/
« no previous file with comments | « pkg/analyzer/lib/src/dart/element/element.dart ('k') | pkg/analyzer/lib/src/summary/link.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698