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

Unified Diff: pkg/analyzer/test/src/dart/element/element_test.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
Index: pkg/analyzer/test/src/dart/element/element_test.dart
diff --git a/pkg/analyzer/test/src/dart/element/element_test.dart b/pkg/analyzer/test/src/dart/element/element_test.dart
index a6e718d83ee3a0efe0d4a7ac3346e332774dfbd5..b8a61fec2a772b51758c221387d0162c489ee307 100644
--- a/pkg/analyzer/test/src/dart/element/element_test.dart
+++ b/pkg/analyzer/test/src/dart/element/element_test.dart
@@ -2782,6 +2782,31 @@ class InterfaceTypeImplTest extends EngineTestCase {
expect(parameterTypes[0], same(typeI));
}
+ void test_getMethod_parameterized_flushCached_whenVersionChanges() {
+ //
+ // class A<E> { E m(E p) {} }
+ //
+ ClassElementImpl classA = ElementFactory.classElement2("A", ["E"]);
+ DartType typeE = classA.type.typeArguments[0];
+ String methodName = "m";
+ MethodElementImpl methodM =
+ ElementFactory.methodElement(methodName, typeE, [typeE]);
+ classA.methods = <MethodElement>[methodM];
+ methodM.type = new FunctionTypeImpl(methodM);
+ //
+ // A<I>
+ //
+ InterfaceType typeI = ElementFactory.classElement2("I").type;
+ InterfaceTypeImpl typeAI = new InterfaceTypeImpl(classA);
+ typeAI.typeArguments = <DartType>[typeI];
+ // Methods list is cached.
+ MethodElement method = typeAI.methods.single;
+ expect(typeAI.methods.single, same(method));
+ // Methods list is flushed on version change.
+ classA.version++;
+ expect(typeAI.methods.single, isNot(same(method)));
+ }
+
void test_getMethod_unimplemented() {
//
// class A {}
« no previous file with comments | « pkg/analyzer/test/src/context/context_test.dart ('k') | pkg/analyzer/test/src/task/incremental_element_builder_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698