| OLD | NEW |
| 1 // This code was auto-generated, is not intended to be edited, and is subject to | 1 // This code was auto-generated, is not intended to be edited, and is subject to |
| 2 // significant change. Please see the README file for more information. | 2 // significant change. Please see the README file for more information. |
| 3 library engine.element; | 3 library engine.element; |
| 4 import 'dart:collection'; | 4 import 'dart:collection'; |
| 5 import 'java_core.dart'; | 5 import 'java_core.dart'; |
| 6 import 'java_engine.dart'; | 6 import 'java_engine.dart'; |
| 7 import 'utilities_collection.dart'; | 7 import 'utilities_collection.dart'; |
| 8 import 'source.dart'; | 8 import 'source.dart'; |
| 9 import 'scanner.dart' show Keyword; | 9 import 'scanner.dart' show Keyword; |
| 10 import 'ast.dart' show Identifier, LibraryIdentifier; | 10 import 'ast.dart' show Identifier, LibraryIdentifier; |
| (...skipping 4294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4305 /** | 4305 /** |
| 4306 * Instances of the class `LocalVariableElementImpl` implement a `LocalVariableE
lement`. | 4306 * Instances of the class `LocalVariableElementImpl` implement a `LocalVariableE
lement`. |
| 4307 * | 4307 * |
| 4308 * @coverage dart.engine.element | 4308 * @coverage dart.engine.element |
| 4309 */ | 4309 */ |
| 4310 class LocalVariableElementImpl extends VariableElementImpl implements LocalVaria
bleElement { | 4310 class LocalVariableElementImpl extends VariableElementImpl implements LocalVaria
bleElement { |
| 4311 | 4311 |
| 4312 /** | 4312 /** |
| 4313 * Is `true` if this variable is potentially mutated somewhere in its scope. | 4313 * Is `true` if this variable is potentially mutated somewhere in its scope. |
| 4314 */ | 4314 */ |
| 4315 bool _isPotentiallyMutated2 = false; | 4315 bool _isPotentiallyMutatedInScope2 = false; |
| 4316 |
| 4317 /** |
| 4318 * Is `true` if this variable is potentially mutated somewhere in closure. |
| 4319 */ |
| 4320 bool _isPotentiallyMutatedInClosure2 = false; |
| 4316 | 4321 |
| 4317 /** | 4322 /** |
| 4318 * The offset to the beginning of the visible range for this element. | 4323 * The offset to the beginning of the visible range for this element. |
| 4319 */ | 4324 */ |
| 4320 int _visibleRangeOffset = 0; | 4325 int _visibleRangeOffset = 0; |
| 4321 | 4326 |
| 4322 /** | 4327 /** |
| 4323 * The length of the visible range for this element, or `-1` if this element d
oes not have a | 4328 * The length of the visible range for this element, or `-1` if this element d
oes not have a |
| 4324 * visible range. | 4329 * visible range. |
| 4325 */ | 4330 */ |
| (...skipping 11 matching lines...) Expand all Loading... |
| 4337 */ | 4342 */ |
| 4338 LocalVariableElementImpl(Identifier name) : super.con1(name); | 4343 LocalVariableElementImpl(Identifier name) : super.con1(name); |
| 4339 accept(ElementVisitor visitor) => visitor.visitLocalVariableElement(this); | 4344 accept(ElementVisitor visitor) => visitor.visitLocalVariableElement(this); |
| 4340 ElementKind get kind => ElementKind.LOCAL_VARIABLE; | 4345 ElementKind get kind => ElementKind.LOCAL_VARIABLE; |
| 4341 SourceRange get visibleRange { | 4346 SourceRange get visibleRange { |
| 4342 if (_visibleRangeLength < 0) { | 4347 if (_visibleRangeLength < 0) { |
| 4343 return null; | 4348 return null; |
| 4344 } | 4349 } |
| 4345 return new SourceRange(_visibleRangeOffset, _visibleRangeLength); | 4350 return new SourceRange(_visibleRangeOffset, _visibleRangeLength); |
| 4346 } | 4351 } |
| 4347 bool get isPotentiallyMutated => _isPotentiallyMutated2; | 4352 bool get isPotentiallyMutatedInClosure => _isPotentiallyMutatedInClosure2; |
| 4353 bool get isPotentiallyMutatedInScope => _isPotentiallyMutatedInScope2; |
| 4354 |
| 4355 /** |
| 4356 * Specifies that this variable is potentially mutated somewhere in closure. |
| 4357 */ |
| 4358 void markPotentiallyMutatedInClosure() { |
| 4359 _isPotentiallyMutatedInClosure2 = true; |
| 4360 } |
| 4348 | 4361 |
| 4349 /** | 4362 /** |
| 4350 * Specifies that this variable is potentially mutated somewhere in its scope. | 4363 * Specifies that this variable is potentially mutated somewhere in its scope. |
| 4351 */ | 4364 */ |
| 4352 void markPotentiallyMutated() { | 4365 void markPotentiallyMutatedInScope() { |
| 4353 _isPotentiallyMutated2 = true; | 4366 _isPotentiallyMutatedInScope2 = true; |
| 4354 } | 4367 } |
| 4355 | 4368 |
| 4356 /** | 4369 /** |
| 4357 * Set the visible range for this element to the range starting at the given o
ffset with the given | 4370 * Set the visible range for this element to the range starting at the given o
ffset with the given |
| 4358 * length. | 4371 * length. |
| 4359 * | 4372 * |
| 4360 * @param offset the offset to the beginning of the visible range for this ele
ment | 4373 * @param offset the offset to the beginning of the visible range for this ele
ment |
| 4361 * @param length the length of the visible range for this element, or `-1` if
this element | 4374 * @param length the length of the visible range for this element, or `-1` if
this element |
| 4362 * does not have a visible range | 4375 * does not have a visible range |
| 4363 */ | 4376 */ |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4606 /** | 4619 /** |
| 4607 * Instances of the class `ParameterElementImpl` implement a `ParameterElement`. | 4620 * Instances of the class `ParameterElementImpl` implement a `ParameterElement`. |
| 4608 * | 4621 * |
| 4609 * @coverage dart.engine.element | 4622 * @coverage dart.engine.element |
| 4610 */ | 4623 */ |
| 4611 class ParameterElementImpl extends VariableElementImpl implements ParameterEleme
nt { | 4624 class ParameterElementImpl extends VariableElementImpl implements ParameterEleme
nt { |
| 4612 | 4625 |
| 4613 /** | 4626 /** |
| 4614 * Is `true` if this variable is potentially mutated somewhere in its scope. | 4627 * Is `true` if this variable is potentially mutated somewhere in its scope. |
| 4615 */ | 4628 */ |
| 4616 bool _isPotentiallyMutated3 = false; | 4629 bool _isPotentiallyMutatedInScope3 = false; |
| 4630 |
| 4631 /** |
| 4632 * Is `true` if this variable is potentially mutated somewhere in closure. |
| 4633 */ |
| 4634 bool _isPotentiallyMutatedInClosure3 = false; |
| 4617 | 4635 |
| 4618 /** | 4636 /** |
| 4619 * An array containing all of the parameters defined by this parameter element
. There will only be | 4637 * An array containing all of the parameters defined by this parameter element
. There will only be |
| 4620 * parameters if this parameter is a function typed parameter. | 4638 * parameters if this parameter is a function typed parameter. |
| 4621 */ | 4639 */ |
| 4622 List<ParameterElement> _parameters = ParameterElementImpl.EMPTY_ARRAY; | 4640 List<ParameterElement> _parameters = ParameterElementImpl.EMPTY_ARRAY; |
| 4623 | 4641 |
| 4624 /** | 4642 /** |
| 4625 * The kind of this parameter. | 4643 * The kind of this parameter. |
| 4626 */ | 4644 */ |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4678 ElementKind get kind => ElementKind.PARAMETER; | 4696 ElementKind get kind => ElementKind.PARAMETER; |
| 4679 ParameterKind get parameterKind => _parameterKind; | 4697 ParameterKind get parameterKind => _parameterKind; |
| 4680 List<ParameterElement> get parameters => _parameters; | 4698 List<ParameterElement> get parameters => _parameters; |
| 4681 SourceRange get visibleRange { | 4699 SourceRange get visibleRange { |
| 4682 if (_visibleRangeLength < 0) { | 4700 if (_visibleRangeLength < 0) { |
| 4683 return null; | 4701 return null; |
| 4684 } | 4702 } |
| 4685 return new SourceRange(_visibleRangeOffset, _visibleRangeLength); | 4703 return new SourceRange(_visibleRangeOffset, _visibleRangeLength); |
| 4686 } | 4704 } |
| 4687 bool get isInitializingFormal => false; | 4705 bool get isInitializingFormal => false; |
| 4688 bool get isPotentiallyMutated => _isPotentiallyMutated3; | 4706 bool get isPotentiallyMutatedInClosure => _isPotentiallyMutatedInClosure3; |
| 4707 bool get isPotentiallyMutatedInScope => _isPotentiallyMutatedInScope3; |
| 4708 |
| 4709 /** |
| 4710 * Specifies that this variable is potentially mutated somewhere in closure. |
| 4711 */ |
| 4712 void markPotentiallyMutatedInClosure() { |
| 4713 _isPotentiallyMutatedInClosure3 = true; |
| 4714 } |
| 4689 | 4715 |
| 4690 /** | 4716 /** |
| 4691 * Specifies that this variable is potentially mutated somewhere in its scope. | 4717 * Specifies that this variable is potentially mutated somewhere in its scope. |
| 4692 */ | 4718 */ |
| 4693 void markPotentiallyMutated() { | 4719 void markPotentiallyMutatedInScope() { |
| 4694 _isPotentiallyMutated3 = true; | 4720 _isPotentiallyMutatedInScope3 = true; |
| 4695 } | 4721 } |
| 4696 | 4722 |
| 4697 /** | 4723 /** |
| 4698 * Set the range of the default value for this parameter to the range starting
at the given offset | 4724 * Set the range of the default value for this parameter to the range starting
at the given offset |
| 4699 * with the given length. | 4725 * with the given length. |
| 4700 * | 4726 * |
| 4701 * @param offset the offset to the beginning of the default value range for th
is element | 4727 * @param offset the offset to the beginning of the default value range for th
is element |
| 4702 * @param length the length of the default value range for this element, or `-
1` if this | 4728 * @param length the length of the default value range for this element, or `-
1` if this |
| 4703 * element does not have a default value | 4729 * element does not have a default value |
| 4704 */ | 4730 */ |
| (...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5184 * | 5210 * |
| 5185 * @return the result of evaluating this variable's initializer | 5211 * @return the result of evaluating this variable's initializer |
| 5186 */ | 5212 */ |
| 5187 EvaluationResultImpl get evaluationResult => null; | 5213 EvaluationResultImpl get evaluationResult => null; |
| 5188 FunctionElement get initializer => _initializer; | 5214 FunctionElement get initializer => _initializer; |
| 5189 Type2 get type => _type; | 5215 Type2 get type => _type; |
| 5190 bool get isConst => hasModifier(Modifier.CONST); | 5216 bool get isConst => hasModifier(Modifier.CONST); |
| 5191 bool get isFinal => hasModifier(Modifier.FINAL); | 5217 bool get isFinal => hasModifier(Modifier.FINAL); |
| 5192 | 5218 |
| 5193 /** | 5219 /** |
| 5220 * Return `true` if this variable is potentially mutated somewhere in closure.
This |
| 5221 * information is only available for local variables (including parameters). |
| 5222 * |
| 5223 * @return `true` if this variable is potentially mutated somewhere in closure |
| 5224 */ |
| 5225 bool get isPotentiallyMutatedInClosure => false; |
| 5226 |
| 5227 /** |
| 5194 * Return `true` if this variable is potentially mutated somewhere in its scop
e. This | 5228 * Return `true` if this variable is potentially mutated somewhere in its scop
e. This |
| 5195 * information is only available for local variables (including parameters). | 5229 * information is only available for local variables (including parameters). |
| 5196 * | 5230 * |
| 5197 * @return `true` if this variable is potentially mutated somewhere in its sco
pe | 5231 * @return `true` if this variable is potentially mutated somewhere in its sco
pe |
| 5198 */ | 5232 */ |
| 5199 bool get isPotentiallyMutated => false; | 5233 bool get isPotentiallyMutatedInScope => false; |
| 5200 | 5234 |
| 5201 /** | 5235 /** |
| 5202 * Set whether this variable is const to correspond to the given value. | 5236 * Set whether this variable is const to correspond to the given value. |
| 5203 * | 5237 * |
| 5204 * @param isConst `true` if the variable is const | 5238 * @param isConst `true` if the variable is const |
| 5205 */ | 5239 */ |
| 5206 void set const3(bool isConst) { | 5240 void set const3(bool isConst) { |
| 5207 setModifier(Modifier.CONST, isConst); | 5241 setModifier(Modifier.CONST, isConst); |
| 5208 } | 5242 } |
| 5209 | 5243 |
| (...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5828 * The unique instance of this class. | 5862 * The unique instance of this class. |
| 5829 */ | 5863 */ |
| 5830 static final BottomTypeImpl instance = new BottomTypeImpl(); | 5864 static final BottomTypeImpl instance = new BottomTypeImpl(); |
| 5831 | 5865 |
| 5832 /** | 5866 /** |
| 5833 * Prevent the creation of instances of this class. | 5867 * Prevent the creation of instances of this class. |
| 5834 */ | 5868 */ |
| 5835 BottomTypeImpl() : super(null, "<bottom>"); | 5869 BottomTypeImpl() : super(null, "<bottom>"); |
| 5836 bool operator ==(Object object) => identical(object, this); | 5870 bool operator ==(Object object) => identical(object, this); |
| 5837 bool get isBottom => true; | 5871 bool get isBottom => true; |
| 5838 bool isMoreSpecificThan(Type2 type) => true; | 5872 bool isMoreSpecificThan3(Type2 type, bool withDynamic) => true; |
| 5839 bool isSubtypeOf(Type2 type) => true; | 5873 bool isSubtypeOf(Type2 type) => true; |
| 5840 bool isSupertypeOf(Type2 type) => false; | 5874 bool isSupertypeOf(Type2 type) => false; |
| 5841 BottomTypeImpl substitute2(List<Type2> argumentTypes, List<Type2> parameterTyp
es) => this; | 5875 BottomTypeImpl substitute2(List<Type2> argumentTypes, List<Type2> parameterTyp
es) => this; |
| 5842 } | 5876 } |
| 5843 /** | 5877 /** |
| 5844 * The unique instance of the class `DynamicTypeImpl` implements the type `dynam
ic`. | 5878 * The unique instance of the class `DynamicTypeImpl` implements the type `dynam
ic`. |
| 5845 * | 5879 * |
| 5846 * @coverage dart.engine.type | 5880 * @coverage dart.engine.type |
| 5847 */ | 5881 */ |
| 5848 class DynamicTypeImpl extends TypeImpl { | 5882 class DynamicTypeImpl extends TypeImpl { |
| 5849 | 5883 |
| 5850 /** | 5884 /** |
| 5851 * The unique instance of this class. | 5885 * The unique instance of this class. |
| 5852 */ | 5886 */ |
| 5853 static final DynamicTypeImpl instance = new DynamicTypeImpl(); | 5887 static final DynamicTypeImpl instance = new DynamicTypeImpl(); |
| 5854 | 5888 |
| 5855 /** | 5889 /** |
| 5856 * Prevent the creation of instances of this class. | 5890 * Prevent the creation of instances of this class. |
| 5857 */ | 5891 */ |
| 5858 DynamicTypeImpl() : super(new DynamicElementImpl(), Keyword.DYNAMIC.syntax) { | 5892 DynamicTypeImpl() : super(new DynamicElementImpl(), Keyword.DYNAMIC.syntax) { |
| 5859 ((element as DynamicElementImpl)).type = this; | 5893 ((element as DynamicElementImpl)).type = this; |
| 5860 } | 5894 } |
| 5861 bool operator ==(Object object) => object is DynamicTypeImpl; | 5895 bool operator ==(Object object) => object is DynamicTypeImpl; |
| 5862 bool get isDynamic => true; | 5896 bool get isDynamic => true; |
| 5863 bool isMoreSpecificThan(Type2 type) { | 5897 bool isMoreSpecificThan3(Type2 type, bool withDynamic) { |
| 5864 if (identical(this, type)) { | 5898 if (identical(this, type)) { |
| 5865 return true; | 5899 return true; |
| 5866 } | 5900 } |
| 5867 return false; | 5901 return withDynamic; |
| 5868 } | 5902 } |
| 5869 bool isSubtypeOf(Type2 type) => true; | 5903 bool isSubtypeOf(Type2 type) => true; |
| 5870 bool isSupertypeOf(Type2 type) => true; | 5904 bool isSupertypeOf(Type2 type) => true; |
| 5871 Type2 substitute2(List<Type2> argumentTypes, List<Type2> parameterTypes) { | 5905 Type2 substitute2(List<Type2> argumentTypes, List<Type2> parameterTypes) { |
| 5872 int length = parameterTypes.length; | 5906 int length = parameterTypes.length; |
| 5873 for (int i = 0; i < length; i++) { | 5907 for (int i = 0; i < length; i++) { |
| 5874 if (parameterTypes[i] == this) { | 5908 if (parameterTypes[i] == this) { |
| 5875 return argumentTypes[i]; | 5909 return argumentTypes[i]; |
| 5876 } | 5910 } |
| 5877 } | 5911 } |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6079 return TypeParameterElementImpl.EMPTY_ARRAY; | 6113 return TypeParameterElementImpl.EMPTY_ARRAY; |
| 6080 } | 6114 } |
| 6081 int get hashCode { | 6115 int get hashCode { |
| 6082 Element element = this.element; | 6116 Element element = this.element; |
| 6083 if (element == null) { | 6117 if (element == null) { |
| 6084 return 0; | 6118 return 0; |
| 6085 } | 6119 } |
| 6086 return element.hashCode; | 6120 return element.hashCode; |
| 6087 } | 6121 } |
| 6088 bool isAssignableTo(Type2 type) => this.isSubtypeOf(type); | 6122 bool isAssignableTo(Type2 type) => this.isSubtypeOf(type); |
| 6089 bool isMoreSpecificThan(Type2 type) { | 6123 bool isMoreSpecificThan3(Type2 type, bool withDynamic) { |
| 6090 if (type == null) { | 6124 if (type == null) { |
| 6091 return false; | 6125 return false; |
| 6092 } else if (identical(this, type) || type.isDynamic || type.isDartCoreFunctio
n || type.isObject) { | 6126 } else if (identical(this, type) || type.isDynamic || type.isDartCoreFunctio
n || type.isObject) { |
| 6093 return true; | 6127 return true; |
| 6094 } else if (type is! FunctionType) { | 6128 } else if (type is! FunctionType) { |
| 6095 return false; | 6129 return false; |
| 6096 } else if (this == type) { | 6130 } else if (this == type) { |
| 6097 return true; | 6131 return true; |
| 6098 } | 6132 } |
| 6099 FunctionType t = this; | 6133 FunctionType t = this; |
| 6100 FunctionType s = type as FunctionType; | 6134 FunctionType s = type as FunctionType; |
| 6101 List<Type2> tTypes = t.normalParameterTypes; | 6135 List<Type2> tTypes = t.normalParameterTypes; |
| 6102 List<Type2> tOpTypes = t.optionalParameterTypes; | 6136 List<Type2> tOpTypes = t.optionalParameterTypes; |
| 6103 List<Type2> sTypes = s.normalParameterTypes; | 6137 List<Type2> sTypes = s.normalParameterTypes; |
| 6104 List<Type2> sOpTypes = s.optionalParameterTypes; | 6138 List<Type2> sOpTypes = s.optionalParameterTypes; |
| 6105 if ((sOpTypes.length > 0 && t.namedParameterTypes.length > 0) || (tOpTypes.l
ength > 0 && s.namedParameterTypes.length > 0)) { | 6139 if ((sOpTypes.length > 0 && t.namedParameterTypes.length > 0) || (tOpTypes.l
ength > 0 && s.namedParameterTypes.length > 0)) { |
| 6106 return false; | 6140 return false; |
| 6107 } | 6141 } |
| 6108 if (t.namedParameterTypes.length > 0) { | 6142 if (t.namedParameterTypes.length > 0) { |
| 6109 if (t.normalParameterTypes.length != s.normalParameterTypes.length) { | 6143 if (t.normalParameterTypes.length != s.normalParameterTypes.length) { |
| 6110 return false; | 6144 return false; |
| 6111 } else if (t.normalParameterTypes.length > 0) { | 6145 } else if (t.normalParameterTypes.length > 0) { |
| 6112 for (int i = 0; i < tTypes.length; i++) { | 6146 for (int i = 0; i < tTypes.length; i++) { |
| 6113 if (!tTypes[i].isMoreSpecificThan(sTypes[i])) { | 6147 if (!tTypes[i].isMoreSpecificThan3(sTypes[i], withDynamic)) { |
| 6114 return false; | 6148 return false; |
| 6115 } | 6149 } |
| 6116 } | 6150 } |
| 6117 } | 6151 } |
| 6118 Map<String, Type2> namedTypesT = t.namedParameterTypes; | 6152 Map<String, Type2> namedTypesT = t.namedParameterTypes; |
| 6119 Map<String, Type2> namedTypesS = s.namedParameterTypes; | 6153 Map<String, Type2> namedTypesS = s.namedParameterTypes; |
| 6120 if (namedTypesT.length < namedTypesS.length) { | 6154 if (namedTypesT.length < namedTypesS.length) { |
| 6121 return false; | 6155 return false; |
| 6122 } | 6156 } |
| 6123 JavaIterator<MapEntry<String, Type2>> iteratorS = new JavaIterator(getMapE
ntrySet(namedTypesS)); | 6157 JavaIterator<MapEntry<String, Type2>> iteratorS = new JavaIterator(getMapE
ntrySet(namedTypesS)); |
| 6124 while (iteratorS.hasNext) { | 6158 while (iteratorS.hasNext) { |
| 6125 MapEntry<String, Type2> entryS = iteratorS.next(); | 6159 MapEntry<String, Type2> entryS = iteratorS.next(); |
| 6126 Type2 typeT = namedTypesT[entryS.getKey()]; | 6160 Type2 typeT = namedTypesT[entryS.getKey()]; |
| 6127 if (typeT == null) { | 6161 if (typeT == null) { |
| 6128 return false; | 6162 return false; |
| 6129 } | 6163 } |
| 6130 if (!typeT.isMoreSpecificThan(entryS.getValue())) { | 6164 if (!typeT.isMoreSpecificThan3(entryS.getValue(), withDynamic)) { |
| 6131 return false; | 6165 return false; |
| 6132 } | 6166 } |
| 6133 } | 6167 } |
| 6134 } else if (s.namedParameterTypes.length > 0) { | 6168 } else if (s.namedParameterTypes.length > 0) { |
| 6135 return false; | 6169 return false; |
| 6136 } else { | 6170 } else { |
| 6137 int tArgLength = tTypes.length + tOpTypes.length; | 6171 int tArgLength = tTypes.length + tOpTypes.length; |
| 6138 int sArgLength = sTypes.length + sOpTypes.length; | 6172 int sArgLength = sTypes.length + sOpTypes.length; |
| 6139 if (tArgLength < sArgLength || sTypes.length < tTypes.length) { | 6173 if (tArgLength < sArgLength || sTypes.length < tTypes.length) { |
| 6140 return false; | 6174 return false; |
| 6141 } | 6175 } |
| 6142 if (tOpTypes.length == 0 && sOpTypes.length == 0) { | 6176 if (tOpTypes.length == 0 && sOpTypes.length == 0) { |
| 6143 for (int i = 0; i < sTypes.length; i++) { | 6177 for (int i = 0; i < sTypes.length; i++) { |
| 6144 if (!tTypes[i].isMoreSpecificThan(sTypes[i])) { | 6178 if (!tTypes[i].isMoreSpecificThan3(sTypes[i], withDynamic)) { |
| 6145 return false; | 6179 return false; |
| 6146 } | 6180 } |
| 6147 } | 6181 } |
| 6148 } else { | 6182 } else { |
| 6149 List<Type2> tAllTypes = new List<Type2>(sArgLength); | 6183 List<Type2> tAllTypes = new List<Type2>(sArgLength); |
| 6150 for (int i = 0; i < tTypes.length; i++) { | 6184 for (int i = 0; i < tTypes.length; i++) { |
| 6151 tAllTypes[i] = tTypes[i]; | 6185 tAllTypes[i] = tTypes[i]; |
| 6152 } | 6186 } |
| 6153 for (int i = tTypes.length, j = 0; i < sArgLength; i++, j++) { | 6187 for (int i = tTypes.length, j = 0; i < sArgLength; i++, j++) { |
| 6154 tAllTypes[i] = tOpTypes[j]; | 6188 tAllTypes[i] = tOpTypes[j]; |
| 6155 } | 6189 } |
| 6156 List<Type2> sAllTypes = new List<Type2>(sArgLength); | 6190 List<Type2> sAllTypes = new List<Type2>(sArgLength); |
| 6157 for (int i = 0; i < sTypes.length; i++) { | 6191 for (int i = 0; i < sTypes.length; i++) { |
| 6158 sAllTypes[i] = sTypes[i]; | 6192 sAllTypes[i] = sTypes[i]; |
| 6159 } | 6193 } |
| 6160 for (int i = sTypes.length, j = 0; i < sArgLength; i++, j++) { | 6194 for (int i = sTypes.length, j = 0; i < sArgLength; i++, j++) { |
| 6161 sAllTypes[i] = sOpTypes[j]; | 6195 sAllTypes[i] = sOpTypes[j]; |
| 6162 } | 6196 } |
| 6163 for (int i = 0; i < sAllTypes.length; i++) { | 6197 for (int i = 0; i < sAllTypes.length; i++) { |
| 6164 if (!tAllTypes[i].isMoreSpecificThan(sAllTypes[i])) { | 6198 if (!tAllTypes[i].isMoreSpecificThan3(sAllTypes[i], withDynamic)) { |
| 6165 return false; | 6199 return false; |
| 6166 } | 6200 } |
| 6167 } | 6201 } |
| 6168 } | 6202 } |
| 6169 } | 6203 } |
| 6170 Type2 tRetType = t.returnType; | 6204 Type2 tRetType = t.returnType; |
| 6171 Type2 sRetType = s.returnType; | 6205 Type2 sRetType = s.returnType; |
| 6172 return sRetType.isVoid || tRetType.isMoreSpecificThan(sRetType); | 6206 return sRetType.isVoid || tRetType.isMoreSpecificThan3(sRetType, withDynamic
); |
| 6173 } | 6207 } |
| 6174 bool isSubtypeOf(Type2 type) { | 6208 bool isSubtypeOf(Type2 type) { |
| 6175 if (type == null) { | 6209 if (type == null) { |
| 6176 return false; | 6210 return false; |
| 6177 } else if (identical(this, type) || type.isDynamic || type.isDartCoreFunctio
n || type.isObject) { | 6211 } else if (identical(this, type) || type.isDynamic || type.isDartCoreFunctio
n || type.isObject) { |
| 6178 return true; | 6212 return true; |
| 6179 } else if (type is! FunctionType) { | 6213 } else if (type is! FunctionType) { |
| 6180 return false; | 6214 return false; |
| 6181 } else if (this == type) { | 6215 } else if (this == type) { |
| 6182 return true; | 6216 return true; |
| (...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6691 return element.hashCode; | 6725 return element.hashCode; |
| 6692 } | 6726 } |
| 6693 bool get isDartCoreFunction { | 6727 bool get isDartCoreFunction { |
| 6694 ClassElement element = this.element; | 6728 ClassElement element = this.element; |
| 6695 if (element == null) { | 6729 if (element == null) { |
| 6696 return false; | 6730 return false; |
| 6697 } | 6731 } |
| 6698 return element.name == "Function" && element.library.isDartCore; | 6732 return element.name == "Function" && element.library.isDartCore; |
| 6699 } | 6733 } |
| 6700 bool isDirectSupertypeOf(InterfaceType type) { | 6734 bool isDirectSupertypeOf(InterfaceType type) { |
| 6701 ClassElement i = element; | 6735 InterfaceType i = this; |
| 6702 ClassElement j = type.element; | 6736 InterfaceType j = type; |
| 6703 InterfaceType supertype = j.supertype; | 6737 ClassElement jElement = j.element; |
| 6738 InterfaceType supertype = jElement.supertype; |
| 6704 if (supertype == null) { | 6739 if (supertype == null) { |
| 6705 return false; | 6740 return false; |
| 6706 } | 6741 } |
| 6707 ClassElement supertypeElement = supertype.element; | 6742 List<Type2> jArgs = j.typeArguments; |
| 6708 if (supertypeElement == i) { | 6743 List<Type2> jVars = jElement.type.typeArguments; |
| 6744 supertype = supertype.substitute2(jArgs, jVars); |
| 6745 if (supertype == i) { |
| 6709 return true; | 6746 return true; |
| 6710 } | 6747 } |
| 6711 for (InterfaceType interfaceType in j.interfaces) { | 6748 for (InterfaceType interfaceType in jElement.interfaces) { |
| 6712 if (interfaceType.element == i) { | 6749 interfaceType = interfaceType.substitute2(jArgs, jVars); |
| 6750 if (interfaceType == i) { |
| 6713 return true; | 6751 return true; |
| 6714 } | 6752 } |
| 6715 } | 6753 } |
| 6716 for (InterfaceType mixinType in j.mixins) { | 6754 for (InterfaceType mixinType in jElement.mixins) { |
| 6717 if (mixinType.element == i) { | 6755 mixinType = mixinType.substitute2(jArgs, jVars); |
| 6756 if (mixinType == i) { |
| 6718 return true; | 6757 return true; |
| 6719 } | 6758 } |
| 6720 } | 6759 } |
| 6721 return false; | 6760 return false; |
| 6722 } | 6761 } |
| 6723 bool isMoreSpecificThan(Type2 type) { | 6762 bool isMoreSpecificThan3(Type2 type, bool withDynamic) { |
| 6724 if (identical(type, DynamicTypeImpl.instance)) { | 6763 if (identical(type, DynamicTypeImpl.instance)) { |
| 6725 return true; | 6764 return true; |
| 6726 } else if (type is! InterfaceType) { | 6765 } else if (type is! InterfaceType) { |
| 6727 return false; | 6766 return false; |
| 6728 } | 6767 } |
| 6729 return isMoreSpecificThan2(type as InterfaceType, new Set<ClassElement>()); | 6768 return isMoreSpecificThan2(type as InterfaceType, new Set<ClassElement>(), w
ithDynamic); |
| 6730 } | 6769 } |
| 6731 bool get isObject => element.supertype == null; | 6770 bool get isObject => element.supertype == null; |
| 6732 bool isSubtypeOf(Type2 type) { | 6771 bool isSubtypeOf(Type2 type) { |
| 6733 if (identical(type, DynamicTypeImpl.instance)) { | 6772 if (identical(type, DynamicTypeImpl.instance)) { |
| 6734 return true; | 6773 return true; |
| 6735 } else if (type is TypeParameterType) { | 6774 } else if (type is TypeParameterType) { |
| 6736 return true; | 6775 return true; |
| 6737 } else if (type is FunctionType) { | 6776 } else if (type is FunctionType) { |
| 6738 ClassElement element = this.element; | 6777 ClassElement element = this.element; |
| 6739 MethodElement callMethod = element.lookUpMethod("call", element.library); | 6778 MethodElement callMethod = element.lookUpMethod("call", element.library); |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6894 builder.append("<"); | 6933 builder.append("<"); |
| 6895 for (int i = 0; i < argumentCount; i++) { | 6934 for (int i = 0; i < argumentCount; i++) { |
| 6896 if (i > 0) { | 6935 if (i > 0) { |
| 6897 builder.append(", "); | 6936 builder.append(", "); |
| 6898 } | 6937 } |
| 6899 ((_typeArguments[i] as TypeImpl)).appendTo(builder); | 6938 ((_typeArguments[i] as TypeImpl)).appendTo(builder); |
| 6900 } | 6939 } |
| 6901 builder.append(">"); | 6940 builder.append(">"); |
| 6902 } | 6941 } |
| 6903 } | 6942 } |
| 6904 bool isMoreSpecificThan2(InterfaceType s, Set<ClassElement> visitedClasses) { | 6943 bool isMoreSpecificThan2(InterfaceType s, Set<ClassElement> visitedClasses, bo
ol withDynamic) { |
| 6905 if (this == s) { | 6944 if (this == s) { |
| 6906 return true; | 6945 return true; |
| 6907 } | 6946 } |
| 6908 if (s.isDirectSupertypeOf(this)) { | 6947 if (s.isDirectSupertypeOf(this)) { |
| 6909 return true; | 6948 return true; |
| 6910 } | 6949 } |
| 6911 ClassElement tElement = this.element; | 6950 ClassElement tElement = this.element; |
| 6912 ClassElement sElement = s.element; | 6951 ClassElement sElement = s.element; |
| 6913 if (tElement == sElement) { | 6952 if (tElement == sElement) { |
| 6914 List<Type2> tArguments = typeArguments; | 6953 List<Type2> tArguments = typeArguments; |
| 6915 List<Type2> sArguments = s.typeArguments; | 6954 List<Type2> sArguments = s.typeArguments; |
| 6916 if (tArguments.length != sArguments.length) { | 6955 if (tArguments.length != sArguments.length) { |
| 6917 return false; | 6956 return false; |
| 6918 } | 6957 } |
| 6919 for (int i = 0; i < tArguments.length; i++) { | 6958 for (int i = 0; i < tArguments.length; i++) { |
| 6920 if (!tArguments[i].isMoreSpecificThan(sArguments[i])) { | 6959 if (!tArguments[i].isMoreSpecificThan3(sArguments[i], withDynamic)) { |
| 6921 return false; | 6960 return false; |
| 6922 } | 6961 } |
| 6923 } | 6962 } |
| 6924 return true; | 6963 return true; |
| 6925 } | 6964 } |
| 6926 ClassElement element = this.element; | 6965 ClassElement element = this.element; |
| 6927 if (element == null || visitedClasses.contains(element)) { | 6966 if (element == null || visitedClasses.contains(element)) { |
| 6928 return false; | 6967 return false; |
| 6929 } | 6968 } |
| 6930 javaSetAdd(visitedClasses, element); | 6969 javaSetAdd(visitedClasses, element); |
| 6931 InterfaceType supertype = superclass; | 6970 InterfaceType supertype = superclass; |
| 6932 if (supertype != null && ((supertype as InterfaceTypeImpl)).isMoreSpecificTh
an2(s, visitedClasses)) { | 6971 if (supertype != null && ((supertype as InterfaceTypeImpl)).isMoreSpecificTh
an2(s, visitedClasses, withDynamic)) { |
| 6933 return true; | 6972 return true; |
| 6934 } | 6973 } |
| 6935 for (InterfaceType interfaceType in interfaces) { | 6974 for (InterfaceType interfaceType in interfaces) { |
| 6936 if (((interfaceType as InterfaceTypeImpl)).isMoreSpecificThan2(s, visitedC
lasses)) { | 6975 if (((interfaceType as InterfaceTypeImpl)).isMoreSpecificThan2(s, visitedC
lasses, withDynamic)) { |
| 6937 return true; | 6976 return true; |
| 6938 } | 6977 } |
| 6939 } | 6978 } |
| 6940 for (InterfaceType mixinType in mixins) { | 6979 for (InterfaceType mixinType in mixins) { |
| 6941 if (((mixinType as InterfaceTypeImpl)).isMoreSpecificThan2(s, visitedClass
es)) { | 6980 if (((mixinType as InterfaceTypeImpl)).isMoreSpecificThan2(s, visitedClass
es, withDynamic)) { |
| 6942 return true; | 6981 return true; |
| 6943 } | 6982 } |
| 6944 } | 6983 } |
| 6945 return false; | 6984 return false; |
| 6946 } | 6985 } |
| 6947 bool isSubtypeOf2(InterfaceType type, Set<ClassElement> visitedClasses) { | 6986 bool isSubtypeOf2(InterfaceType type, Set<ClassElement> visitedClasses) { |
| 6948 InterfaceType typeT = this; | 6987 InterfaceType typeT = this; |
| 6949 InterfaceType typeS = type; | 6988 InterfaceType typeS = type; |
| 6950 ClassElement elementT = element; | 6989 ClassElement elementT = element; |
| 6951 if (elementT == null || visitedClasses.contains(elementT)) { | 6990 if (elementT == null || visitedClasses.contains(elementT)) { |
| 6952 return false; | 6991 return false; |
| 6953 } | 6992 } |
| 6954 javaSetAdd(visitedClasses, elementT); | 6993 javaSetAdd(visitedClasses, elementT); |
| 6955 typeT = substitute2(_typeArguments, elementT.type.typeArguments); | |
| 6956 if (typeT == typeS) { | 6994 if (typeT == typeS) { |
| 6957 return true; | 6995 return true; |
| 6958 } else if (elementT == typeS.element) { | 6996 } else if (elementT == typeS.element) { |
| 6959 List<Type2> typeTArgs = typeT.typeArguments; | 6997 List<Type2> typeTArgs = typeT.typeArguments; |
| 6960 List<Type2> typeSArgs = typeS.typeArguments; | 6998 List<Type2> typeSArgs = typeS.typeArguments; |
| 6961 if (typeTArgs.length != typeSArgs.length) { | 6999 if (typeTArgs.length != typeSArgs.length) { |
| 6962 return false; | 7000 return false; |
| 6963 } | 7001 } |
| 6964 for (int i = 0; i < typeTArgs.length; i++) { | 7002 for (int i = 0; i < typeTArgs.length; i++) { |
| 6965 if (!typeTArgs[i].isSubtypeOf(typeSArgs[i])) { | 7003 if (!typeTArgs[i].isSubtypeOf(typeSArgs[i])) { |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7045 this._name = name; | 7083 this._name = name; |
| 7046 } | 7084 } |
| 7047 String get displayName => name; | 7085 String get displayName => name; |
| 7048 Element get element => _element; | 7086 Element get element => _element; |
| 7049 Type2 getLeastUpperBound(Type2 type) => null; | 7087 Type2 getLeastUpperBound(Type2 type) => null; |
| 7050 String get name => _name; | 7088 String get name => _name; |
| 7051 bool isAssignableTo(Type2 type) => this.isSubtypeOf(type) || type.isSubtypeOf(
this); | 7089 bool isAssignableTo(Type2 type) => this.isSubtypeOf(type) || type.isSubtypeOf(
this); |
| 7052 bool get isBottom => false; | 7090 bool get isBottom => false; |
| 7053 bool get isDartCoreFunction => false; | 7091 bool get isDartCoreFunction => false; |
| 7054 bool get isDynamic => false; | 7092 bool get isDynamic => false; |
| 7055 bool isMoreSpecificThan(Type2 type) => false; | 7093 bool isMoreSpecificThan(Type2 type) => isMoreSpecificThan3(type, false); |
| 7094 bool isMoreSpecificThan3(Type2 type, bool withDynamic) => false; |
| 7056 bool get isObject => false; | 7095 bool get isObject => false; |
| 7057 bool isSupertypeOf(Type2 type) => type.isSubtypeOf(this); | 7096 bool isSupertypeOf(Type2 type) => type.isSubtypeOf(this); |
| 7058 bool get isVoid => false; | 7097 bool get isVoid => false; |
| 7059 String toString() { | 7098 String toString() { |
| 7060 JavaStringBuilder builder = new JavaStringBuilder(); | 7099 JavaStringBuilder builder = new JavaStringBuilder(); |
| 7061 appendTo(builder); | 7100 appendTo(builder); |
| 7062 return builder.toString(); | 7101 return builder.toString(); |
| 7063 } | 7102 } |
| 7064 | 7103 |
| 7065 /** | 7104 /** |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7111 /** | 7150 /** |
| 7112 * Initialize a newly created type parameter type to be declared by the given
element and to have | 7151 * Initialize a newly created type parameter type to be declared by the given
element and to have |
| 7113 * the given name. | 7152 * the given name. |
| 7114 * | 7153 * |
| 7115 * @param element the element representing the declaration of the type paramet
er | 7154 * @param element the element representing the declaration of the type paramet
er |
| 7116 */ | 7155 */ |
| 7117 TypeParameterTypeImpl(TypeParameterElement element) : super(element, element.n
ame); | 7156 TypeParameterTypeImpl(TypeParameterElement element) : super(element, element.n
ame); |
| 7118 bool operator ==(Object object) => object is TypeParameterTypeImpl && (element
== ((object as TypeParameterTypeImpl)).element); | 7157 bool operator ==(Object object) => object is TypeParameterTypeImpl && (element
== ((object as TypeParameterTypeImpl)).element); |
| 7119 TypeParameterElement get element => super.element as TypeParameterElement; | 7158 TypeParameterElement get element => super.element as TypeParameterElement; |
| 7120 int get hashCode => element.hashCode; | 7159 int get hashCode => element.hashCode; |
| 7121 bool isMoreSpecificThan(Type2 s) { | 7160 bool isMoreSpecificThan3(Type2 s, bool withDynamic) { |
| 7122 if (this == s) { | 7161 if (this == s) { |
| 7123 return true; | 7162 return true; |
| 7124 } | 7163 } |
| 7125 if (s.isBottom) { | 7164 if (s.isBottom) { |
| 7126 return true; | 7165 return true; |
| 7127 } | 7166 } |
| 7128 if (s.isDynamic) { | 7167 if (s.isDynamic) { |
| 7129 return true; | 7168 return true; |
| 7130 } | 7169 } |
| 7131 return isMoreSpecificThan3(s, new Set<Type2>()); | 7170 return isMoreSpecificThan4(s, new Set<Type2>(), withDynamic); |
| 7132 } | 7171 } |
| 7133 bool isSubtypeOf(Type2 s) => isMoreSpecificThan(s); | 7172 bool isSubtypeOf(Type2 s) => isMoreSpecificThan3(s, true); |
| 7134 Type2 substitute2(List<Type2> argumentTypes, List<Type2> parameterTypes) { | 7173 Type2 substitute2(List<Type2> argumentTypes, List<Type2> parameterTypes) { |
| 7135 int length = parameterTypes.length; | 7174 int length = parameterTypes.length; |
| 7136 for (int i = 0; i < length; i++) { | 7175 for (int i = 0; i < length; i++) { |
| 7137 if (parameterTypes[i] == this) { | 7176 if (parameterTypes[i] == this) { |
| 7138 return argumentTypes[i]; | 7177 return argumentTypes[i]; |
| 7139 } | 7178 } |
| 7140 } | 7179 } |
| 7141 return this; | 7180 return this; |
| 7142 } | 7181 } |
| 7143 bool isMoreSpecificThan3(Type2 s, Set<Type2> visitedTypes) { | 7182 bool isMoreSpecificThan4(Type2 s, Set<Type2> visitedTypes, bool withDynamic) { |
| 7144 Type2 bound = element.bound; | 7183 Type2 bound = element.bound; |
| 7145 if (s == bound) { | 7184 if (s == bound) { |
| 7146 return true; | 7185 return true; |
| 7147 } | 7186 } |
| 7148 if (s.isObject) { | 7187 if (s.isObject) { |
| 7149 return true; | 7188 return true; |
| 7150 } | 7189 } |
| 7151 if (bound == null) { | 7190 if (bound == null) { |
| 7152 return false; | 7191 return false; |
| 7153 } | 7192 } |
| 7154 if (bound is TypeParameterTypeImpl) { | 7193 if (bound is TypeParameterTypeImpl) { |
| 7155 TypeParameterTypeImpl boundTypeParameter = bound as TypeParameterTypeImpl; | 7194 TypeParameterTypeImpl boundTypeParameter = bound as TypeParameterTypeImpl; |
| 7156 if (visitedTypes.contains(bound)) { | 7195 if (visitedTypes.contains(bound)) { |
| 7157 return false; | 7196 return false; |
| 7158 } | 7197 } |
| 7159 javaSetAdd(visitedTypes, bound); | 7198 javaSetAdd(visitedTypes, bound); |
| 7160 return boundTypeParameter.isMoreSpecificThan3(s, visitedTypes); | 7199 return boundTypeParameter.isMoreSpecificThan4(s, visitedTypes, withDynamic
); |
| 7161 } | 7200 } |
| 7162 return bound.isMoreSpecificThan(s); | 7201 return bound.isMoreSpecificThan3(s, withDynamic); |
| 7163 } | 7202 } |
| 7164 } | 7203 } |
| 7165 /** | 7204 /** |
| 7166 * The unique instance of the class `VoidTypeImpl` implements the type `void`. | 7205 * The unique instance of the class `VoidTypeImpl` implements the type `void`. |
| 7167 * | 7206 * |
| 7168 * @coverage dart.engine.type | 7207 * @coverage dart.engine.type |
| 7169 */ | 7208 */ |
| 7170 class VoidTypeImpl extends TypeImpl implements VoidType { | 7209 class VoidTypeImpl extends TypeImpl implements VoidType { |
| 7171 | 7210 |
| 7172 /** | 7211 /** |
| (...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7725 | 7764 |
| 7726 /** | 7765 /** |
| 7727 * Return `true` if this type is more specific than the given type. | 7766 * Return `true` if this type is more specific than the given type. |
| 7728 * | 7767 * |
| 7729 * @param type the type being compared with this type | 7768 * @param type the type being compared with this type |
| 7730 * @return `true` if this type is more specific than the given type | 7769 * @return `true` if this type is more specific than the given type |
| 7731 */ | 7770 */ |
| 7732 bool isMoreSpecificThan(Type2 type); | 7771 bool isMoreSpecificThan(Type2 type); |
| 7733 | 7772 |
| 7734 /** | 7773 /** |
| 7774 * Return `true` if this type is more specific than the given type. |
| 7775 * |
| 7776 * @param type the type being compared with this type |
| 7777 * @param withDynamic `true` if "dynamic" should be considered as a subtype of
any type |
| 7778 * @return `true` if this type is more specific than the given type |
| 7779 */ |
| 7780 bool isMoreSpecificThan3(Type2 type, bool withDynamic); |
| 7781 |
| 7782 /** |
| 7735 * Return `true` if this type represents the type 'Object'. | 7783 * Return `true` if this type represents the type 'Object'. |
| 7736 * | 7784 * |
| 7737 * @return `true` if this type represents the type 'Object' | 7785 * @return `true` if this type represents the type 'Object' |
| 7738 */ | 7786 */ |
| 7739 bool get isObject; | 7787 bool get isObject; |
| 7740 | 7788 |
| 7741 /** | 7789 /** |
| 7742 * Return `true` if this type is a subtype of the given type. | 7790 * Return `true` if this type is a subtype of the given type. |
| 7743 * | 7791 * |
| 7744 * @param type the type being compared with this type | 7792 * @param type the type being compared with this type |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7788 } | 7836 } |
| 7789 /** | 7837 /** |
| 7790 * The interface `VoidType` defines the behavior of the unique object representi
ng the type | 7838 * The interface `VoidType` defines the behavior of the unique object representi
ng the type |
| 7791 * `void`. | 7839 * `void`. |
| 7792 * | 7840 * |
| 7793 * @coverage dart.engine.type | 7841 * @coverage dart.engine.type |
| 7794 */ | 7842 */ |
| 7795 abstract class VoidType implements Type2 { | 7843 abstract class VoidType implements Type2 { |
| 7796 VoidType substitute2(List<Type2> argumentTypes, List<Type2> parameterTypes); | 7844 VoidType substitute2(List<Type2> argumentTypes, List<Type2> parameterTypes); |
| 7797 } | 7845 } |
| OLD | NEW |