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. |
*/ |