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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library analyzer.test.src.dart.element.element_test; 5 library analyzer.test.src.dart.element.element_test;
6 6
7 import 'package:analyzer/dart/ast/ast.dart'; 7 import 'package:analyzer/dart/ast/ast.dart';
8 import 'package:analyzer/dart/constant/value.dart'; 8 import 'package:analyzer/dart/constant/value.dart';
9 import 'package:analyzer/dart/element/element.dart'; 9 import 'package:analyzer/dart/element/element.dart';
10 import 'package:analyzer/dart/element/type.dart'; 10 import 'package:analyzer/dart/element/type.dart';
(...skipping 2764 matching lines...) Expand 10 before | Expand all | Expand 10 after
2775 typeAI.typeArguments = <DartType>[typeI]; 2775 typeAI.typeArguments = <DartType>[typeI];
2776 MethodElement method = typeAI.getMethod(methodName); 2776 MethodElement method = typeAI.getMethod(methodName);
2777 expect(method, isNotNull); 2777 expect(method, isNotNull);
2778 FunctionType methodType = method.type; 2778 FunctionType methodType = method.type;
2779 expect(methodType.returnType, same(typeI)); 2779 expect(methodType.returnType, same(typeI));
2780 List<DartType> parameterTypes = methodType.normalParameterTypes; 2780 List<DartType> parameterTypes = methodType.normalParameterTypes;
2781 expect(parameterTypes, hasLength(1)); 2781 expect(parameterTypes, hasLength(1));
2782 expect(parameterTypes[0], same(typeI)); 2782 expect(parameterTypes[0], same(typeI));
2783 } 2783 }
2784 2784
2785 void test_getMethod_parameterized_flushCached_whenVersionChanges() {
2786 //
2787 // class A<E> { E m(E p) {} }
2788 //
2789 ClassElementImpl classA = ElementFactory.classElement2("A", ["E"]);
2790 DartType typeE = classA.type.typeArguments[0];
2791 String methodName = "m";
2792 MethodElementImpl methodM =
2793 ElementFactory.methodElement(methodName, typeE, [typeE]);
2794 classA.methods = <MethodElement>[methodM];
2795 methodM.type = new FunctionTypeImpl(methodM);
2796 //
2797 // A<I>
2798 //
2799 InterfaceType typeI = ElementFactory.classElement2("I").type;
2800 InterfaceTypeImpl typeAI = new InterfaceTypeImpl(classA);
2801 typeAI.typeArguments = <DartType>[typeI];
2802 // Methods list is cached.
2803 MethodElement method = typeAI.methods.single;
2804 expect(typeAI.methods.single, same(method));
2805 // Methods list is flushed on version change.
2806 classA.version++;
2807 expect(typeAI.methods.single, isNot(same(method)));
2808 }
2809
2785 void test_getMethod_unimplemented() { 2810 void test_getMethod_unimplemented() {
2786 // 2811 //
2787 // class A {} 2812 // class A {}
2788 // 2813 //
2789 ClassElementImpl classA = ElementFactory.classElement2("A"); 2814 ClassElementImpl classA = ElementFactory.classElement2("A");
2790 InterfaceType typeA = classA.type; 2815 InterfaceType typeA = classA.type;
2791 expect(typeA.getMethod("m"), isNull); 2816 expect(typeA.getMethod("m"), isNull);
2792 } 2817 }
2793 2818
2794 void test_getMethods() { 2819 void test_getMethods() {
(...skipping 1667 matching lines...) Expand 10 before | Expand all | Expand 10 after
4462 } 4487 }
4463 4488
4464 class _FunctionTypeImplTest_isSubtypeOf_baseCase_classFunction 4489 class _FunctionTypeImplTest_isSubtypeOf_baseCase_classFunction
4465 extends InterfaceTypeImpl { 4490 extends InterfaceTypeImpl {
4466 _FunctionTypeImplTest_isSubtypeOf_baseCase_classFunction(ClassElement arg0) 4491 _FunctionTypeImplTest_isSubtypeOf_baseCase_classFunction(ClassElement arg0)
4467 : super(arg0); 4492 : super(arg0);
4468 4493
4469 @override 4494 @override
4470 bool get isDartCoreFunction => true; 4495 bool get isDartCoreFunction => true;
4471 } 4496 }
OLDNEW
« 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