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

Side by Side Diff: pkg/analyzer/lib/src/generated/element.dart

Issue 1268733004: Propagate a type in asynchronous for-in statements (issue 23945) (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 4 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
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/generated/resolver.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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; 8 library engine.element;
9 9
10 import 'dart:collection'; 10 import 'dart:collection';
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 int get hashCode => 0; 78 int get hashCode => 0;
79 79
80 @override 80 @override
81 bool get isBottom => true; 81 bool get isBottom => true;
82 82
83 @override 83 @override
84 bool operator ==(Object object) => identical(object, this); 84 bool operator ==(Object object) => identical(object, this);
85 85
86 @override 86 @override
87 bool isMoreSpecificThan(DartType type, 87 bool isMoreSpecificThan(DartType type,
88 [bool withDynamic = false, Set<Element> visitedElements]) => true; 88 [bool withDynamic = false, Set<Element> visitedElements]) =>
89 true;
89 90
90 @override 91 @override
91 bool isSubtypeOf(DartType type) => true; 92 bool isSubtypeOf(DartType type) => true;
92 93
93 @override 94 @override
94 bool isSupertypeOf(DartType type) => false; 95 bool isSupertypeOf(DartType type) => false;
95 96
96 @override 97 @override
97 TypeImpl pruned(List<FunctionTypeAliasElement> prune) => this; 98 TypeImpl pruned(List<FunctionTypeAliasElement> prune) => this;
98 99
99 @override 100 @override
100 BottomTypeImpl substitute2( 101 BottomTypeImpl substitute2(
101 List<DartType> argumentTypes, List<DartType> parameterTypes, 102 List<DartType> argumentTypes, List<DartType> parameterTypes,
102 [List<FunctionTypeAliasElement> prune]) => this; 103 [List<FunctionTypeAliasElement> prune]) =>
104 this;
103 } 105 }
104 106
105 /** 107 /**
106 * Type created internally if a circular reference is ever detected. Behaves 108 * Type created internally if a circular reference is ever detected. Behaves
107 * like `dynamic`, except that when converted to a string it is displayed as 109 * like `dynamic`, except that when converted to a string it is displayed as
108 * `...`. 110 * `...`.
109 */ 111 */
110 class CircularTypeImpl extends DynamicTypeImpl { 112 class CircularTypeImpl extends DynamicTypeImpl {
111 CircularTypeImpl() : super._circular(); 113 CircularTypeImpl() : super._circular();
112 114
(...skipping 1034 matching lines...) Expand 10 before | Expand all | Expand 10 after
1147 1149
1148 PropertyAccessorElement _internalLookUpConcreteGetter( 1150 PropertyAccessorElement _internalLookUpConcreteGetter(
1149 String getterName, LibraryElement library, bool includeThisClass) { 1151 String getterName, LibraryElement library, bool includeThisClass) {
1150 PropertyAccessorElement getter = 1152 PropertyAccessorElement getter =
1151 _internalLookUpGetter(getterName, library, includeThisClass); 1153 _internalLookUpGetter(getterName, library, includeThisClass);
1152 while (getter != null && getter.isAbstract) { 1154 while (getter != null && getter.isAbstract) {
1153 Element definingClass = getter.enclosingElement; 1155 Element definingClass = getter.enclosingElement;
1154 if (definingClass is! ClassElementImpl) { 1156 if (definingClass is! ClassElementImpl) {
1155 return null; 1157 return null;
1156 } 1158 }
1157 getter = (definingClass as ClassElementImpl)._internalLookUpGetter( 1159 getter = (definingClass as ClassElementImpl)
1158 getterName, library, false); 1160 ._internalLookUpGetter(getterName, library, false);
1159 } 1161 }
1160 return getter; 1162 return getter;
1161 } 1163 }
1162 1164
1163 MethodElement _internalLookUpConcreteMethod( 1165 MethodElement _internalLookUpConcreteMethod(
1164 String methodName, LibraryElement library, bool includeThisClass) { 1166 String methodName, LibraryElement library, bool includeThisClass) {
1165 MethodElement method = 1167 MethodElement method =
1166 _internalLookUpMethod(methodName, library, includeThisClass); 1168 _internalLookUpMethod(methodName, library, includeThisClass);
1167 while (method != null && method.isAbstract) { 1169 while (method != null && method.isAbstract) {
1168 ClassElement definingClass = method.enclosingElement; 1170 ClassElement definingClass = method.enclosingElement;
1169 if (definingClass == null) { 1171 if (definingClass == null) {
1170 return null; 1172 return null;
1171 } 1173 }
1172 method = definingClass.lookUpInheritedMethod(methodName, library); 1174 method = definingClass.lookUpInheritedMethod(methodName, library);
1173 } 1175 }
1174 return method; 1176 return method;
1175 } 1177 }
1176 1178
1177 PropertyAccessorElement _internalLookUpConcreteSetter( 1179 PropertyAccessorElement _internalLookUpConcreteSetter(
1178 String setterName, LibraryElement library, bool includeThisClass) { 1180 String setterName, LibraryElement library, bool includeThisClass) {
1179 PropertyAccessorElement setter = 1181 PropertyAccessorElement setter =
1180 _internalLookUpSetter(setterName, library, includeThisClass); 1182 _internalLookUpSetter(setterName, library, includeThisClass);
1181 while (setter != null && setter.isAbstract) { 1183 while (setter != null && setter.isAbstract) {
1182 Element definingClass = setter.enclosingElement; 1184 Element definingClass = setter.enclosingElement;
1183 if (definingClass is! ClassElementImpl) { 1185 if (definingClass is! ClassElementImpl) {
1184 return null; 1186 return null;
1185 } 1187 }
1186 setter = (definingClass as ClassElementImpl)._internalLookUpSetter( 1188 setter = (definingClass as ClassElementImpl)
1187 setterName, library, false); 1189 ._internalLookUpSetter(setterName, library, false);
1188 } 1190 }
1189 return setter; 1191 return setter;
1190 } 1192 }
1191 1193
1192 PropertyAccessorElement _internalLookUpGetter( 1194 PropertyAccessorElement _internalLookUpGetter(
1193 String getterName, LibraryElement library, bool includeThisClass) { 1195 String getterName, LibraryElement library, bool includeThisClass) {
1194 HashSet<ClassElement> visitedClasses = new HashSet<ClassElement>(); 1196 HashSet<ClassElement> visitedClasses = new HashSet<ClassElement>();
1195 ClassElement currentElement = this; 1197 ClassElement currentElement = this;
1196 if (includeThisClass) { 1198 if (includeThisClass) {
1197 PropertyAccessorElement element = currentElement.getGetter(getterName); 1199 PropertyAccessorElement element = currentElement.getGetter(getterName);
(...skipping 1334 matching lines...) Expand 10 before | Expand all | Expand 10 after
2532 2534
2533 /** 2535 /**
2534 * Return the offset of the name of this element in the file that contains the 2536 * Return the offset of the name of this element in the file that contains the
2535 * declaration of this element, or `-1` if this element is synthetic, does not 2537 * declaration of this element, or `-1` if this element is synthetic, does not
2536 * have a name, or otherwise does not have an offset. 2538 * have a name, or otherwise does not have an offset.
2537 */ 2539 */
2538 int get nameOffset; 2540 int get nameOffset;
2539 2541
2540 /** 2542 /**
2541 * **DEPRECATED** Use `computeNode()` instead. 2543 * **DEPRECATED** Use `computeNode()` instead.
2542 * 2544 *
2543 * Return the resolved [AstNode] node that declares this element, or `null` if 2545 * Return the resolved [AstNode] node that declares this element, or `null` if
2544 * this element is synthetic or isn't contained in a compilation unit, such as 2546 * this element is synthetic or isn't contained in a compilation unit, such as
2545 * a [LibraryElement]. 2547 * a [LibraryElement].
2546 * 2548 *
2547 * This method is expensive, because resolved AST might be evicted from cache, 2549 * This method is expensive, because resolved AST might be evicted from cache,
2548 * so parsing and resolving will be performed. 2550 * so parsing and resolving will be performed.
2549 * 2551 *
2550 * <b>Note:</b> This method cannot be used in an async environment. 2552 * <b>Note:</b> This method cannot be used in an async environment.
2551 */ 2553 */
2552 @deprecated 2554 @deprecated
(...skipping 1529 matching lines...) Expand 10 before | Expand all | Expand 10 after
4082 * so parsing and resolving will be performed. 4084 * so parsing and resolving will be performed.
4083 */ 4085 */
4084 @override 4086 @override
4085 AstNode computeNode(); 4087 AstNode computeNode();
4086 } 4088 }
4087 4089
4088 /** 4090 /**
4089 * A concrete implementation of a [FieldElement]. 4091 * A concrete implementation of a [FieldElement].
4090 */ 4092 */
4091 class FieldElementImpl extends PropertyInducingElementImpl 4093 class FieldElementImpl extends PropertyInducingElementImpl
4092 with PotentiallyConstVariableElement implements FieldElement { 4094 with PotentiallyConstVariableElement
4095 implements FieldElement {
4093 /** 4096 /**
4094 * An empty list of field elements. 4097 * An empty list of field elements.
4095 */ 4098 */
4096 @deprecated // Use FieldElement.EMPTY_LIST 4099 @deprecated // Use FieldElement.EMPTY_LIST
4097 static const List<FieldElement> EMPTY_ARRAY = const <FieldElement>[]; 4100 static const List<FieldElement> EMPTY_ARRAY = const <FieldElement>[];
4098 4101
4099 /** 4102 /**
4100 * Initialize a newly created synthetic field element to have the given [name] 4103 * Initialize a newly created synthetic field element to have the given [name]
4101 * at the given [offset]. 4104 * at the given [offset].
4102 */ 4105 */
(...skipping 853 matching lines...) Expand 10 before | Expand all | Expand 10 after
4956 if (parameters.length == 0) { 4959 if (parameters.length == 0) {
4957 return namedParameterTypes; 4960 return namedParameterTypes;
4958 } 4961 }
4959 List<DartType> typeParameters = 4962 List<DartType> typeParameters =
4960 TypeParameterTypeImpl.getTypes(this.typeParameters); 4963 TypeParameterTypeImpl.getTypes(this.typeParameters);
4961 for (ParameterElement parameter in parameters) { 4964 for (ParameterElement parameter in parameters) {
4962 if (parameter.parameterKind == ParameterKind.NAMED) { 4965 if (parameter.parameterKind == ParameterKind.NAMED) {
4963 DartType type = parameter.type; 4966 DartType type = parameter.type;
4964 if (typeArguments.length != 0 && 4967 if (typeArguments.length != 0 &&
4965 typeArguments.length == typeParameters.length) { 4968 typeArguments.length == typeParameters.length) {
4966 type = (type as TypeImpl).substitute2( 4969 type = (type as TypeImpl)
4967 typeArguments, typeParameters, newPrune); 4970 .substitute2(typeArguments, typeParameters, newPrune);
4968 } else { 4971 } else {
4969 type = (type as TypeImpl).pruned(newPrune); 4972 type = (type as TypeImpl).pruned(newPrune);
4970 } 4973 }
4971 namedParameterTypes[parameter.name] = type; 4974 namedParameterTypes[parameter.name] = type;
4972 } 4975 }
4973 } 4976 }
4974 return namedParameterTypes; 4977 return namedParameterTypes;
4975 } 4978 }
4976 4979
4977 /** 4980 /**
(...skipping 24 matching lines...) Expand all
5002 return DartType.EMPTY_LIST; 5005 return DartType.EMPTY_LIST;
5003 } 5006 }
5004 List<DartType> typeParameters = 5007 List<DartType> typeParameters =
5005 TypeParameterTypeImpl.getTypes(this.typeParameters); 5008 TypeParameterTypeImpl.getTypes(this.typeParameters);
5006 List<DartType> types = new List<DartType>(); 5009 List<DartType> types = new List<DartType>();
5007 for (ParameterElement parameter in parameters) { 5010 for (ParameterElement parameter in parameters) {
5008 if (parameter.parameterKind == ParameterKind.REQUIRED) { 5011 if (parameter.parameterKind == ParameterKind.REQUIRED) {
5009 DartType type = parameter.type; 5012 DartType type = parameter.type;
5010 if (typeArguments.length != 0 && 5013 if (typeArguments.length != 0 &&
5011 typeArguments.length == typeParameters.length) { 5014 typeArguments.length == typeParameters.length) {
5012 type = (type as TypeImpl).substitute2( 5015 type = (type as TypeImpl)
5013 typeArguments, typeParameters, newPrune); 5016 .substitute2(typeArguments, typeParameters, newPrune);
5014 } else { 5017 } else {
5015 type = (type as TypeImpl).pruned(newPrune); 5018 type = (type as TypeImpl).pruned(newPrune);
5016 } 5019 }
5017 types.add(type); 5020 types.add(type);
5018 } 5021 }
5019 } 5022 }
5020 return types; 5023 return types;
5021 } 5024 }
5022 5025
5023 @override 5026 @override
5024 List<DartType> get optionalParameterTypes { 5027 List<DartType> get optionalParameterTypes {
5025 List<ParameterElement> parameters = baseParameters; 5028 List<ParameterElement> parameters = baseParameters;
5026 if (parameters.length == 0) { 5029 if (parameters.length == 0) {
5027 return DartType.EMPTY_LIST; 5030 return DartType.EMPTY_LIST;
5028 } 5031 }
5029 List<DartType> typeParameters = 5032 List<DartType> typeParameters =
5030 TypeParameterTypeImpl.getTypes(this.typeParameters); 5033 TypeParameterTypeImpl.getTypes(this.typeParameters);
5031 List<DartType> types = new List<DartType>(); 5034 List<DartType> types = new List<DartType>();
5032 for (ParameterElement parameter in parameters) { 5035 for (ParameterElement parameter in parameters) {
5033 if (parameter.parameterKind == ParameterKind.POSITIONAL) { 5036 if (parameter.parameterKind == ParameterKind.POSITIONAL) {
5034 DartType type = parameter.type; 5037 DartType type = parameter.type;
5035 if (typeArguments.length != 0 && 5038 if (typeArguments.length != 0 &&
5036 typeArguments.length == typeParameters.length) { 5039 typeArguments.length == typeParameters.length) {
5037 type = (type as TypeImpl).substitute2( 5040 type = (type as TypeImpl)
5038 typeArguments, typeParameters, newPrune); 5041 .substitute2(typeArguments, typeParameters, newPrune);
5039 } else { 5042 } else {
5040 type = (type as TypeImpl).pruned(newPrune); 5043 type = (type as TypeImpl).pruned(newPrune);
5041 } 5044 }
5042 types.add(type); 5045 types.add(type);
5043 } 5046 }
5044 } 5047 }
5045 return types; 5048 return types;
5046 } 5049 }
5047 5050
5048 @override 5051 @override
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
5210 return false; 5213 return false;
5211 } 5214 }
5212 // named parameters case 5215 // named parameters case
5213 if (t.namedParameterTypes.length > 0) { 5216 if (t.namedParameterTypes.length > 0) {
5214 // check that the number of required parameters are equal, and check that 5217 // check that the number of required parameters are equal, and check that
5215 // every t_i is more specific than every s_i 5218 // every t_i is more specific than every s_i
5216 if (t.normalParameterTypes.length != s.normalParameterTypes.length) { 5219 if (t.normalParameterTypes.length != s.normalParameterTypes.length) {
5217 return false; 5220 return false;
5218 } else if (t.normalParameterTypes.length > 0) { 5221 } else if (t.normalParameterTypes.length > 0) {
5219 for (int i = 0; i < tTypes.length; i++) { 5222 for (int i = 0; i < tTypes.length; i++) {
5220 if (!(tTypes[i] as TypeImpl).isMoreSpecificThan( 5223 if (!(tTypes[i] as TypeImpl)
5221 sTypes[i], withDynamic)) { 5224 .isMoreSpecificThan(sTypes[i], withDynamic)) {
5222 return false; 5225 return false;
5223 } 5226 }
5224 } 5227 }
5225 } 5228 }
5226 Map<String, DartType> namedTypesT = t.namedParameterTypes; 5229 Map<String, DartType> namedTypesT = t.namedParameterTypes;
5227 Map<String, DartType> namedTypesS = s.namedParameterTypes; 5230 Map<String, DartType> namedTypesS = s.namedParameterTypes;
5228 // if k >= m is false, return false: the passed function type has more 5231 // if k >= m is false, return false: the passed function type has more
5229 // named parameter types than this 5232 // named parameter types than this
5230 if (namedTypesT.length < namedTypesS.length) { 5233 if (namedTypesT.length < namedTypesS.length) {
5231 return false; 5234 return false;
5232 } 5235 }
5233 // Loop through each element in S verifying that T has a matching 5236 // Loop through each element in S verifying that T has a matching
5234 // parameter name and that the corresponding type is more specific then 5237 // parameter name and that the corresponding type is more specific then
5235 // the type in S. 5238 // the type in S.
5236 for (String keyS in namedTypesS.keys) { 5239 for (String keyS in namedTypesS.keys) {
5237 DartType typeT = namedTypesT[keyS]; 5240 DartType typeT = namedTypesT[keyS];
5238 if (typeT == null) { 5241 if (typeT == null) {
5239 return false; 5242 return false;
5240 } 5243 }
5241 if (!(typeT as TypeImpl).isMoreSpecificThan( 5244 if (!(typeT as TypeImpl)
5242 namedTypesS[keyS], withDynamic)) { 5245 .isMoreSpecificThan(namedTypesS[keyS], withDynamic)) {
5243 return false; 5246 return false;
5244 } 5247 }
5245 } 5248 }
5246 } else if (s.namedParameterTypes.length > 0) { 5249 } else if (s.namedParameterTypes.length > 0) {
5247 return false; 5250 return false;
5248 } else { 5251 } else {
5249 // positional parameter case 5252 // positional parameter case
5250 int tArgLength = tTypes.length + tOpTypes.length; 5253 int tArgLength = tTypes.length + tOpTypes.length;
5251 int sArgLength = sTypes.length + sOpTypes.length; 5254 int sArgLength = sTypes.length + sOpTypes.length;
5252 // Check that the total number of parameters in t is greater than or equal 5255 // Check that the total number of parameters in t is greater than or equal
5253 // to the number of parameters in s and that the number of required 5256 // to the number of parameters in s and that the number of required
5254 // parameters in s is greater than or equal to the number of required 5257 // parameters in s is greater than or equal to the number of required
5255 // parameters in t. 5258 // parameters in t.
5256 if (tArgLength < sArgLength || sTypes.length < tTypes.length) { 5259 if (tArgLength < sArgLength || sTypes.length < tTypes.length) {
5257 return false; 5260 return false;
5258 } 5261 }
5259 if (tOpTypes.length == 0 && sOpTypes.length == 0) { 5262 if (tOpTypes.length == 0 && sOpTypes.length == 0) {
5260 // No positional arguments, don't copy contents to new array 5263 // No positional arguments, don't copy contents to new array
5261 for (int i = 0; i < sTypes.length; i++) { 5264 for (int i = 0; i < sTypes.length; i++) {
5262 if (!(tTypes[i] as TypeImpl).isMoreSpecificThan( 5265 if (!(tTypes[i] as TypeImpl)
5263 sTypes[i], withDynamic)) { 5266 .isMoreSpecificThan(sTypes[i], withDynamic)) {
5264 return false; 5267 return false;
5265 } 5268 }
5266 } 5269 }
5267 } else { 5270 } else {
5268 // Else, we do have positional parameters, copy required and positional 5271 // Else, we do have positional parameters, copy required and positional
5269 // parameter types into arrays to do the compare (for loop below). 5272 // parameter types into arrays to do the compare (for loop below).
5270 List<DartType> tAllTypes = new List<DartType>(sArgLength); 5273 List<DartType> tAllTypes = new List<DartType>(sArgLength);
5271 for (int i = 0; i < tTypes.length; i++) { 5274 for (int i = 0; i < tTypes.length; i++) {
5272 tAllTypes[i] = tTypes[i]; 5275 tAllTypes[i] = tTypes[i];
5273 } 5276 }
5274 for (int i = tTypes.length, j = 0; i < sArgLength; i++, j++) { 5277 for (int i = tTypes.length, j = 0; i < sArgLength; i++, j++) {
5275 tAllTypes[i] = tOpTypes[j]; 5278 tAllTypes[i] = tOpTypes[j];
5276 } 5279 }
5277 List<DartType> sAllTypes = new List<DartType>(sArgLength); 5280 List<DartType> sAllTypes = new List<DartType>(sArgLength);
5278 for (int i = 0; i < sTypes.length; i++) { 5281 for (int i = 0; i < sTypes.length; i++) {
5279 sAllTypes[i] = sTypes[i]; 5282 sAllTypes[i] = sTypes[i];
5280 } 5283 }
5281 for (int i = sTypes.length, j = 0; i < sArgLength; i++, j++) { 5284 for (int i = sTypes.length, j = 0; i < sArgLength; i++, j++) {
5282 sAllTypes[i] = sOpTypes[j]; 5285 sAllTypes[i] = sOpTypes[j];
5283 } 5286 }
5284 for (int i = 0; i < sAllTypes.length; i++) { 5287 for (int i = 0; i < sAllTypes.length; i++) {
5285 if (!(tAllTypes[i] as TypeImpl).isMoreSpecificThan( 5288 if (!(tAllTypes[i] as TypeImpl)
5286 sAllTypes[i], withDynamic)) { 5289 .isMoreSpecificThan(sAllTypes[i], withDynamic)) {
5287 return false; 5290 return false;
5288 } 5291 }
5289 } 5292 }
5290 } 5293 }
5291 } 5294 }
5292 DartType tRetType = t.returnType; 5295 DartType tRetType = t.returnType;
5293 DartType sRetType = s.returnType; 5296 DartType sRetType = s.returnType;
5294 return sRetType.isVoid || 5297 return sRetType.isVoid ||
5295 (tRetType as TypeImpl).isMoreSpecificThan(sRetType, withDynamic); 5298 (tRetType as TypeImpl).isMoreSpecificThan(sRetType, withDynamic);
5296 } 5299 }
(...skipping 1331 matching lines...) Expand 10 before | Expand all | Expand 10 after
6628 // 6631 //
6629 ClassElement tElement = this.element; 6632 ClassElement tElement = this.element;
6630 ClassElement sElement = type.element; 6633 ClassElement sElement = type.element;
6631 if (tElement == sElement) { 6634 if (tElement == sElement) {
6632 List<DartType> tArguments = typeArguments; 6635 List<DartType> tArguments = typeArguments;
6633 List<DartType> sArguments = type.typeArguments; 6636 List<DartType> sArguments = type.typeArguments;
6634 if (tArguments.length != sArguments.length) { 6637 if (tArguments.length != sArguments.length) {
6635 return false; 6638 return false;
6636 } 6639 }
6637 for (int i = 0; i < tArguments.length; i++) { 6640 for (int i = 0; i < tArguments.length; i++) {
6638 if (!(tArguments[i] as TypeImpl).isMoreSpecificThan( 6641 if (!(tArguments[i] as TypeImpl)
6639 sArguments[i], withDynamic)) { 6642 .isMoreSpecificThan(sArguments[i], withDynamic)) {
6640 return false; 6643 return false;
6641 } 6644 }
6642 } 6645 }
6643 return true; 6646 return true;
6644 } 6647 }
6645 } 6648 }
6646 // 6649 //
6647 // Transitivity: T << U and U << S. 6650 // Transitivity: T << U and U << S.
6648 // 6651 //
6649 // First check for infinite loops 6652 // First check for infinite loops
6650 if (element == null) { 6653 if (element == null) {
6651 return false; 6654 return false;
6652 } 6655 }
6653 if (visitedElements == null) { 6656 if (visitedElements == null) {
6654 visitedElements = new HashSet<ClassElement>(); 6657 visitedElements = new HashSet<ClassElement>();
6655 } else if (visitedElements.contains(element)) { 6658 } else if (visitedElements.contains(element)) {
6656 return false; 6659 return false;
6657 } 6660 }
6658 visitedElements.add(element); 6661 visitedElements.add(element);
6659 try { 6662 try {
6660 // Iterate over all of the types U that are more specific than T because 6663 // Iterate over all of the types U that are more specific than T because
6661 // they are direct supertypes of T and return true if any of them are more 6664 // they are direct supertypes of T and return true if any of them are more
6662 // specific than S. 6665 // specific than S.
6663 InterfaceTypeImpl supertype = superclass; 6666 InterfaceTypeImpl supertype = superclass;
6664 if (supertype != null && 6667 if (supertype != null &&
6665 supertype.isMoreSpecificThan(type, withDynamic, visitedElements)) { 6668 supertype.isMoreSpecificThan(type, withDynamic, visitedElements)) {
6666 return true; 6669 return true;
6667 } 6670 }
6668 for (InterfaceType interfaceType in interfaces) { 6671 for (InterfaceType interfaceType in interfaces) {
6669 if ((interfaceType as InterfaceTypeImpl).isMoreSpecificThan( 6672 if ((interfaceType as InterfaceTypeImpl)
6670 type, withDynamic, visitedElements)) { 6673 .isMoreSpecificThan(type, withDynamic, visitedElements)) {
6671 return true; 6674 return true;
6672 } 6675 }
6673 } 6676 }
6674 for (InterfaceType mixinType in mixins) { 6677 for (InterfaceType mixinType in mixins) {
6675 if ((mixinType as InterfaceTypeImpl).isMoreSpecificThan( 6678 if ((mixinType as InterfaceTypeImpl)
6676 type, withDynamic, visitedElements)) { 6679 .isMoreSpecificThan(type, withDynamic, visitedElements)) {
6677 return true; 6680 return true;
6678 } 6681 }
6679 } 6682 }
6680 // If a type I includes an instance method named `call`, and the type of 6683 // If a type I includes an instance method named `call`, and the type of
6681 // `call` is the function type F, then I is considered to be more specific 6684 // `call` is the function type F, then I is considered to be more specific
6682 // than F. 6685 // than F.
6683 MethodElement callMethod = getMethod('call'); 6686 MethodElement callMethod = getMethod('call');
6684 if (callMethod != null && !callMethod.isStatic) { 6687 if (callMethod != null && !callMethod.isStatic) {
6685 FunctionTypeImpl callType = callMethod.type; 6688 FunctionTypeImpl callType = callMethod.type;
6686 if (callType.isMoreSpecificThan(type, withDynamic, visitedElements)) { 6689 if (callType.isMoreSpecificThan(type, withDynamic, visitedElements)) {
(...skipping 953 matching lines...) Expand 10 before | Expand all | Expand 10 after
7640 void _addVisibleLibraries( 7643 void _addVisibleLibraries(
7641 Set<LibraryElement> visibleLibraries, bool includeExports) { 7644 Set<LibraryElement> visibleLibraries, bool includeExports) {
7642 // maybe already processed 7645 // maybe already processed
7643 if (!visibleLibraries.add(this)) { 7646 if (!visibleLibraries.add(this)) {
7644 return; 7647 return;
7645 } 7648 }
7646 // add imported libraries 7649 // add imported libraries
7647 for (ImportElement importElement in _imports) { 7650 for (ImportElement importElement in _imports) {
7648 LibraryElement importedLibrary = importElement.importedLibrary; 7651 LibraryElement importedLibrary = importElement.importedLibrary;
7649 if (importedLibrary != null) { 7652 if (importedLibrary != null) {
7650 (importedLibrary as LibraryElementImpl)._addVisibleLibraries( 7653 (importedLibrary as LibraryElementImpl)
7651 visibleLibraries, true); 7654 ._addVisibleLibraries(visibleLibraries, true);
7652 } 7655 }
7653 } 7656 }
7654 // add exported libraries 7657 // add exported libraries
7655 if (includeExports) { 7658 if (includeExports) {
7656 for (ExportElement exportElement in _exports) { 7659 for (ExportElement exportElement in _exports) {
7657 LibraryElement exportedLibrary = exportElement.exportedLibrary; 7660 LibraryElement exportedLibrary = exportElement.exportedLibrary;
7658 if (exportedLibrary != null) { 7661 if (exportedLibrary != null) {
7659 (exportedLibrary as LibraryElementImpl)._addVisibleLibraries( 7662 (exportedLibrary as LibraryElementImpl)
7660 visibleLibraries, true); 7663 ._addVisibleLibraries(visibleLibraries, true);
7661 } 7664 }
7662 } 7665 }
7663 } 7666 }
7664 } 7667 }
7665 7668
7666 /** 7669 /**
7667 * Return `true` if the given [library] is up to date with respect to the 7670 * Return `true` if the given [library] is up to date with respect to the
7668 * given [timeStamp]. The set of [visitedLibraries] is used to prevent 7671 * given [timeStamp]. The set of [visitedLibraries] is used to prevent
7669 * infinite recusion in the case of mutually dependent libraries. 7672 * infinite recusion in the case of mutually dependent libraries.
7670 */ 7673 */
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
7744 * so parsing and resolving will be performed. 7747 * so parsing and resolving will be performed.
7745 */ 7748 */
7746 @override 7749 @override
7747 VariableDeclaration computeNode(); 7750 VariableDeclaration computeNode();
7748 } 7751 }
7749 7752
7750 /** 7753 /**
7751 * A concrete implementation of a [LocalVariableElement]. 7754 * A concrete implementation of a [LocalVariableElement].
7752 */ 7755 */
7753 class LocalVariableElementImpl extends VariableElementImpl 7756 class LocalVariableElementImpl extends VariableElementImpl
7754 with PotentiallyConstVariableElement implements LocalVariableElement { 7757 with PotentiallyConstVariableElement
7758 implements LocalVariableElement {
7755 /** 7759 /**
7756 * An empty list of field elements. 7760 * An empty list of field elements.
7757 */ 7761 */
7758 @deprecated // Use LocalVariableElement.EMPTY_LIST 7762 @deprecated // Use LocalVariableElement.EMPTY_LIST
7759 static const List<LocalVariableElement> EMPTY_ARRAY = 7763 static const List<LocalVariableElement> EMPTY_ARRAY =
7760 const <LocalVariableElement>[]; 7764 const <LocalVariableElement>[];
7761 7765
7762 /** 7766 /**
7763 * The offset to the beginning of the visible range for this element. 7767 * The offset to the beginning of the visible range for this element.
7764 */ 7768 */
(...skipping 889 matching lines...) Expand 10 before | Expand all | Expand 10 after
8654 List<TypeParameterElement> get typeParameters; 8658 List<TypeParameterElement> get typeParameters;
8655 8659
8656 @override 8660 @override
8657 FormalParameter computeNode(); 8661 FormalParameter computeNode();
8658 } 8662 }
8659 8663
8660 /** 8664 /**
8661 * A concrete implementation of a [ParameterElement]. 8665 * A concrete implementation of a [ParameterElement].
8662 */ 8666 */
8663 class ParameterElementImpl extends VariableElementImpl 8667 class ParameterElementImpl extends VariableElementImpl
8664 with PotentiallyConstVariableElement implements ParameterElement { 8668 with PotentiallyConstVariableElement
8669 implements ParameterElement {
8665 /** 8670 /**
8666 * An empty list of parameter elements. 8671 * An empty list of parameter elements.
8667 */ 8672 */
8668 @deprecated // Use ParameterElement.EMPTY_LIST 8673 @deprecated // Use ParameterElement.EMPTY_LIST
8669 static const List<ParameterElement> EMPTY_ARRAY = const <ParameterElement>[]; 8674 static const List<ParameterElement> EMPTY_ARRAY = const <ParameterElement>[];
8670 8675
8671 /** 8676 /**
8672 * A list containing all of the parameters defined by this parameter element. 8677 * A list containing all of the parameters defined by this parameter element.
8673 * There will only be parameters if this parameter is a function typed 8678 * There will only be parameters if this parameter is a function typed
8674 * parameter. 8679 * parameter.
(...skipping 1168 matching lines...) Expand 10 before | Expand all | Expand 10 after
9843 const <TopLevelVariableElement>[]; 9848 const <TopLevelVariableElement>[];
9844 9849
9845 @override 9850 @override
9846 VariableDeclaration computeNode(); 9851 VariableDeclaration computeNode();
9847 } 9852 }
9848 9853
9849 /** 9854 /**
9850 * A concrete implementation of a [TopLevelVariableElement]. 9855 * A concrete implementation of a [TopLevelVariableElement].
9851 */ 9856 */
9852 class TopLevelVariableElementImpl extends PropertyInducingElementImpl 9857 class TopLevelVariableElementImpl extends PropertyInducingElementImpl
9853 with PotentiallyConstVariableElement implements TopLevelVariableElement { 9858 with PotentiallyConstVariableElement
9859 implements TopLevelVariableElement {
9854 /** 9860 /**
9855 * An empty list of top-level variable elements. 9861 * An empty list of top-level variable elements.
9856 */ 9862 */
9857 @deprecated // Use TopLevelVariableElement.EMPTY_LIST 9863 @deprecated // Use TopLevelVariableElement.EMPTY_LIST
9858 static const List<TopLevelVariableElement> EMPTY_ARRAY = 9864 static const List<TopLevelVariableElement> EMPTY_ARRAY =
9859 const <TopLevelVariableElement>[]; 9865 const <TopLevelVariableElement>[];
9860 9866
9861 /** 9867 /**
9862 * Initialize a newly created synthetic top-level variable element to have the 9868 * Initialize a newly created synthetic top-level variable element to have the
9863 * given [name] and [offset]. 9869 * given [name] and [offset].
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
10086 */ 10092 */
10087 static List<DartType> substitute(List<DartType> types, 10093 static List<DartType> substitute(List<DartType> types,
10088 List<DartType> argumentTypes, List<DartType> parameterTypes, 10094 List<DartType> argumentTypes, List<DartType> parameterTypes,
10089 [List<FunctionTypeAliasElement> prune]) { 10095 [List<FunctionTypeAliasElement> prune]) {
10090 int length = types.length; 10096 int length = types.length;
10091 if (length == 0) { 10097 if (length == 0) {
10092 return types; 10098 return types;
10093 } 10099 }
10094 List<DartType> newTypes = new List<DartType>(length); 10100 List<DartType> newTypes = new List<DartType>(length);
10095 for (int i = 0; i < length; i++) { 10101 for (int i = 0; i < length; i++) {
10096 newTypes[i] = (types[i] as TypeImpl).substitute2( 10102 newTypes[i] = (types[i] as TypeImpl)
10097 argumentTypes, parameterTypes, prune); 10103 .substitute2(argumentTypes, parameterTypes, prune);
10098 } 10104 }
10099 return newTypes; 10105 return newTypes;
10100 } 10106 }
10101 } 10107 }
10102 10108
10103 /** 10109 /**
10104 * A type parameter. 10110 * A type parameter.
10105 */ 10111 */
10106 abstract class TypeParameterElement implements Element { 10112 abstract class TypeParameterElement implements TypeDefiningElement {
10107 /** 10113 /**
10108 * An empty list of type parameter elements. 10114 * An empty list of type parameter elements.
10109 */ 10115 */
10110 static const List<TypeParameterElement> EMPTY_LIST = 10116 static const List<TypeParameterElement> EMPTY_LIST =
10111 const <TypeParameterElement>[]; 10117 const <TypeParameterElement>[];
10112 10118
10113 /** 10119 /**
10114 * Return the type representing the bound associated with this parameter, or 10120 * Return the type representing the bound associated with this parameter, or
10115 * `null` if this parameter does not have an explicit bound. 10121 * `null` if this parameter does not have an explicit bound.
10116 */ 10122 */
(...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after
10690 // bottom <: void (as bottom is a subtype of all types). 10696 // bottom <: void (as bottom is a subtype of all types).
10691 // void <: dynamic (as dynamic is a supertype of all types) 10697 // void <: dynamic (as dynamic is a supertype of all types)
10692 return identical(type, this) || type.isDynamic; 10698 return identical(type, this) || type.isDynamic;
10693 } 10699 }
10694 10700
10695 @override 10701 @override
10696 TypeImpl pruned(List<FunctionTypeAliasElement> prune) => this; 10702 TypeImpl pruned(List<FunctionTypeAliasElement> prune) => this;
10697 10703
10698 @override 10704 @override
10699 VoidTypeImpl substitute2( 10705 VoidTypeImpl substitute2(
10700 List<DartType> argumentTypes, List<DartType> parameterTypes, 10706 List<DartType> argumentTypes, List<DartType> parameterTypes,
10701 [List<FunctionTypeAliasElement> prune]) => this; 10707 [List<FunctionTypeAliasElement> prune]) =>
10708 this;
10702 } 10709 }
10703 10710
10704 /** 10711 /**
10705 * A visitor that visit all the elements recursively and fill the given [map]. 10712 * A visitor that visit all the elements recursively and fill the given [map].
10706 */ 10713 */
10707 class _BuildOffsetToElementMap extends GeneralizingElementVisitor { 10714 class _BuildOffsetToElementMap extends GeneralizingElementVisitor {
10708 final Map<int, Element> map; 10715 final Map<int, Element> map;
10709 10716
10710 _BuildOffsetToElementMap(this.map); 10717 _BuildOffsetToElementMap(this.map);
10711 10718
10712 @override 10719 @override
10713 void visitElement(Element element) { 10720 void visitElement(Element element) {
10714 int offset = element.nameOffset; 10721 int offset = element.nameOffset;
10715 if (offset != -1) { 10722 if (offset != -1) {
10716 map[offset] = element; 10723 map[offset] = element;
10717 } 10724 }
10718 super.visitElement(element); 10725 super.visitElement(element);
10719 } 10726 }
10720 } 10727 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/generated/resolver.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698