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

Side by Side Diff: pkg/analyzer/test/generated/element_test.dart

Issue 879093002: Fix mixin resolution order when multiple mixins present. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 10 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 | Annotate | Revision Log
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 // This code was auto-generated, is not intended to be edited, and is subject to 5 // This code was auto-generated, is not intended to be edited, and is subject to
6 // significant change. Please see the README file for more information. 6 // significant change. Please see the README file for more information.
7 7
8 library engine.element_test; 8 library engine.element_test;
9 9
10 import 'package:analyzer/src/generated/ast.dart'; 10 import 'package:analyzer/src/generated/ast.dart';
(...skipping 3092 matching lines...) Expand 10 before | Expand all | Expand 10 after
3103 classA.accessors = <PropertyAccessorElement>[getterG]; 3103 classA.accessors = <PropertyAccessorElement>[getterG];
3104 ClassElementImpl classB = ElementFactory.classElement("B", classA.type); 3104 ClassElementImpl classB = ElementFactory.classElement("B", classA.type);
3105 InterfaceType typeB = classB.type; 3105 InterfaceType typeB = classB.type;
3106 LibraryElementImpl library = 3106 LibraryElementImpl library =
3107 ElementFactory.library(createAnalysisContext(), "lib"); 3107 ElementFactory.library(createAnalysisContext(), "lib");
3108 CompilationUnitElement unit = library.definingCompilationUnit; 3108 CompilationUnitElement unit = library.definingCompilationUnit;
3109 (unit as CompilationUnitElementImpl).types = <ClassElement>[classA, classB]; 3109 (unit as CompilationUnitElementImpl).types = <ClassElement>[classA, classB];
3110 expect(typeB.lookUpGetter(getterName, library), same(getterG)); 3110 expect(typeB.lookUpGetter(getterName, library), same(getterG));
3111 } 3111 }
3112 3112
3113 void test_lookUpGetter_mixin_shadowing() {
3114 //
3115 // class B {}
3116 // class M1 { get g {} }
3117 // class M2 { get g {} }
3118 // class C extends B with M1, M2 {}
3119 //
3120 TestTypeProvider typeProvider = new TestTypeProvider();
3121 String getterName = 'g';
3122 ClassElementImpl classB = ElementFactory.classElement2('B');
3123 ClassElementImpl classM1 = ElementFactory.classElement2('M1');
3124 PropertyAccessorElementImpl getterM1g =
3125 ElementFactory.getterElement(getterName, false, typeProvider.dynamicType );
3126 classM1.accessors = <PropertyAccessorElement>[getterM1g];
3127 ClassElementImpl classM2 = ElementFactory.classElement2('M2');
3128 PropertyAccessorElementImpl getterM2g =
3129 ElementFactory.getterElement(getterName, false, typeProvider.dynamicType );
3130 classM2.accessors = <PropertyAccessorElement>[getterM2g];
3131 ClassElementImpl classC = ElementFactory.classElement('C', classB.type);
3132 classC.mixins = <InterfaceType>[classM1.type, classM2.type];
3133 LibraryElementImpl library =
3134 ElementFactory.library(createAnalysisContext(), "lib");
3135 CompilationUnitElementImpl unit = library.definingCompilationUnit;
3136 unit.types = <ClassElement>[classB, classM1, classM2, classC];
3137 expect(classC.type.lookUpGetter(getterName, library), getterM2g);
3138 }
3139
3113 void test_lookUpGetter_recursive() { 3140 void test_lookUpGetter_recursive() {
3114 // 3141 //
3115 // class A extends B {} 3142 // class A extends B {}
3116 // class B extends A {} 3143 // class B extends A {}
3117 // 3144 //
3118 ClassElementImpl classA = ElementFactory.classElement2("A"); 3145 ClassElementImpl classA = ElementFactory.classElement2("A");
3119 InterfaceType typeA = classA.type; 3146 InterfaceType typeA = classA.type;
3120 ClassElementImpl classB = ElementFactory.classElement("B", typeA); 3147 ClassElementImpl classB = ElementFactory.classElement("B", typeA);
3121 classA.supertype = classB.type; 3148 classA.supertype = classB.type;
3122 LibraryElementImpl library = 3149 LibraryElementImpl library =
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
3166 classA.methods = <MethodElement>[methodM]; 3193 classA.methods = <MethodElement>[methodM];
3167 ClassElementImpl classB = ElementFactory.classElement("B", classA.type); 3194 ClassElementImpl classB = ElementFactory.classElement("B", classA.type);
3168 InterfaceType typeB = classB.type; 3195 InterfaceType typeB = classB.type;
3169 LibraryElementImpl library = 3196 LibraryElementImpl library =
3170 ElementFactory.library(createAnalysisContext(), "lib"); 3197 ElementFactory.library(createAnalysisContext(), "lib");
3171 CompilationUnitElement unit = library.definingCompilationUnit; 3198 CompilationUnitElement unit = library.definingCompilationUnit;
3172 (unit as CompilationUnitElementImpl).types = <ClassElement>[classA, classB]; 3199 (unit as CompilationUnitElementImpl).types = <ClassElement>[classA, classB];
3173 expect(typeB.lookUpMethod(methodName, library), same(methodM)); 3200 expect(typeB.lookUpMethod(methodName, library), same(methodM));
3174 } 3201 }
3175 3202
3203 void test_lookUpMethod_mixin_shadowing() {
3204 //
3205 // class B {}
3206 // class M1 { m() {} }
3207 // class M2 { m() {} }
3208 // class C extends B with M1, M2 {}
3209 //
3210 String methodName = 'm';
3211 ClassElementImpl classB = ElementFactory.classElement2('B');
3212 ClassElementImpl classM1 = ElementFactory.classElement2('M1');
3213 MethodElementImpl methodM1m =
3214 ElementFactory.methodElement(methodName, null);
3215 classM1.methods = <MethodElement>[methodM1m];
3216 ClassElementImpl classM2 = ElementFactory.classElement2('M2');
3217 MethodElementImpl methodM2m =
3218 ElementFactory.methodElement(methodName, null);
3219 classM2.methods = <MethodElement>[methodM2m];
3220 ClassElementImpl classC = ElementFactory.classElement('C', classB.type);
3221 classC.mixins = <InterfaceType>[classM1.type, classM2.type];
3222 LibraryElementImpl library =
3223 ElementFactory.library(createAnalysisContext(), "lib");
3224 CompilationUnitElementImpl unit = library.definingCompilationUnit;
3225 unit.types = <ClassElement>[classB, classM1, classM2, classC];
3226 expect(classC.type.lookUpMethod(methodName, library), methodM2m);
3227 }
3228
3176 void test_lookUpMethod_parameterized() { 3229 void test_lookUpMethod_parameterized() {
3177 // 3230 //
3178 // class A<E> { E m(E p) {} } 3231 // class A<E> { E m(E p) {} }
3179 // class B<F> extends A<F> {} 3232 // class B<F> extends A<F> {}
3180 // 3233 //
3181 ClassElementImpl classA = ElementFactory.classElement2("A", ["E"]); 3234 ClassElementImpl classA = ElementFactory.classElement2("A", ["E"]);
3182 DartType typeE = classA.type.typeArguments[0]; 3235 DartType typeE = classA.type.typeArguments[0];
3183 String methodName = "m"; 3236 String methodName = "m";
3184 MethodElementImpl methodM = 3237 MethodElementImpl methodM =
3185 ElementFactory.methodElement(methodName, typeE, [typeE]); 3238 ElementFactory.methodElement(methodName, typeE, [typeE]);
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
3268 classA.accessors = <PropertyAccessorElement>[setterS]; 3321 classA.accessors = <PropertyAccessorElement>[setterS];
3269 ClassElementImpl classB = ElementFactory.classElement("B", classA.type); 3322 ClassElementImpl classB = ElementFactory.classElement("B", classA.type);
3270 InterfaceType typeB = classB.type; 3323 InterfaceType typeB = classB.type;
3271 LibraryElementImpl library = 3324 LibraryElementImpl library =
3272 ElementFactory.library(createAnalysisContext(), "lib"); 3325 ElementFactory.library(createAnalysisContext(), "lib");
3273 CompilationUnitElement unit = library.definingCompilationUnit; 3326 CompilationUnitElement unit = library.definingCompilationUnit;
3274 (unit as CompilationUnitElementImpl).types = <ClassElement>[classA, classB]; 3327 (unit as CompilationUnitElementImpl).types = <ClassElement>[classA, classB];
3275 expect(typeB.lookUpSetter(setterName, library), same(setterS)); 3328 expect(typeB.lookUpSetter(setterName, library), same(setterS));
3276 } 3329 }
3277 3330
3331 void test_lookUpSetter_mixin_shadowing() {
3332 //
3333 // class B {}
3334 // class M1 { set s() {} }
3335 // class M2 { set s() {} }
3336 // class C extends B with M1, M2 {}
3337 //
3338 TestTypeProvider typeProvider = new TestTypeProvider();
3339 String setterName = 's';
3340 ClassElementImpl classB = ElementFactory.classElement2('B');
3341 ClassElementImpl classM1 = ElementFactory.classElement2('M1');
3342 PropertyAccessorElementImpl setterM1g =
3343 ElementFactory.setterElement(setterName, false, typeProvider.dynamicType );
3344 classM1.accessors = <PropertyAccessorElement>[setterM1g];
3345 ClassElementImpl classM2 = ElementFactory.classElement2('M2');
3346 PropertyAccessorElementImpl setterM2g =
3347 ElementFactory.getterElement(setterName, false, typeProvider.dynamicType );
3348 classM2.accessors = <PropertyAccessorElement>[setterM2g];
3349 ClassElementImpl classC = ElementFactory.classElement('C', classB.type);
3350 classC.mixins = <InterfaceType>[classM1.type, classM2.type];
3351 LibraryElementImpl library =
3352 ElementFactory.library(createAnalysisContext(), "lib");
3353 CompilationUnitElementImpl unit = library.definingCompilationUnit;
3354 unit.types = <ClassElement>[classB, classM1, classM2, classC];
3355 expect(classC.type.lookUpGetter(setterName, library), setterM2g);
3356 }
3357
3278 void test_lookUpSetter_recursive() { 3358 void test_lookUpSetter_recursive() {
3279 // 3359 //
3280 // class A extends B {} 3360 // class A extends B {}
3281 // class B extends A {} 3361 // class B extends A {}
3282 // 3362 //
3283 ClassElementImpl classA = ElementFactory.classElement2("A"); 3363 ClassElementImpl classA = ElementFactory.classElement2("A");
3284 InterfaceType typeA = classA.type; 3364 InterfaceType typeA = classA.type;
3285 ClassElementImpl classB = ElementFactory.classElement("B", typeA); 3365 ClassElementImpl classB = ElementFactory.classElement("B", typeA);
3286 classA.supertype = classB.type; 3366 classA.supertype = classB.type;
3287 LibraryElementImpl library = 3367 LibraryElementImpl library =
(...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after
3953 4033
3954 class _FunctionTypeImplTest_isSubtypeOf_baseCase_classFunction extends 4034 class _FunctionTypeImplTest_isSubtypeOf_baseCase_classFunction extends
3955 InterfaceTypeImpl { 4035 InterfaceTypeImpl {
3956 4036
3957 _FunctionTypeImplTest_isSubtypeOf_baseCase_classFunction(ClassElement arg0) 4037 _FunctionTypeImplTest_isSubtypeOf_baseCase_classFunction(ClassElement arg0)
3958 : super.con1(arg0); 4038 : super.con1(arg0);
3959 4039
3960 @override 4040 @override
3961 bool get isDartCoreFunction => true; 4041 bool get isDartCoreFunction => true;
3962 } 4042 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/resolver.dart ('k') | pkg/analyzer/test/generated/resolver_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698