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

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

Issue 189803004: Translate private Java members to private Dart members. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Tweaks Created 6 years, 9 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; 8 library engine.element;
9 9
10 import 'dart:collection'; 10 import 'dart:collection';
(...skipping 2518 matching lines...) Expand 10 before | Expand all | Expand 10 after
2529 * @param name the name of this element 2529 * @param name the name of this element
2530 */ 2530 */
2531 ClassElementImpl(Identifier name) : super.con1(name); 2531 ClassElementImpl(Identifier name) : super.con1(name);
2532 2532
2533 accept(ElementVisitor visitor) => visitor.visitClassElement(this); 2533 accept(ElementVisitor visitor) => visitor.visitClassElement(this);
2534 2534
2535 List<PropertyAccessorElement> get accessors => _accessors; 2535 List<PropertyAccessorElement> get accessors => _accessors;
2536 2536
2537 List<InterfaceType> get allSupertypes { 2537 List<InterfaceType> get allSupertypes {
2538 List<InterfaceType> list = new List<InterfaceType>(); 2538 List<InterfaceType> list = new List<InterfaceType>();
2539 collectAllSupertypes(list); 2539 _collectAllSupertypes(list);
2540 return new List.from(list); 2540 return new List.from(list);
2541 } 2541 }
2542 2542
2543 ElementImpl getChild(String identifier) { 2543 ElementImpl getChild(String identifier) {
2544 // 2544 //
2545 // The casts in this method are safe because the set methods would have thro wn a CCE if any of 2545 // The casts in this method are safe because the set methods would have thro wn a CCE if any of
2546 // the elements in the arrays were not of the expected types. 2546 // the elements in the arrays were not of the expected types.
2547 // 2547 //
2548 for (PropertyAccessorElement accessor in _accessors) { 2548 for (PropertyAccessorElement accessor in _accessors) {
2549 if ((accessor as PropertyAccessorElementImpl).identifier == identifier) { 2549 if ((accessor as PropertyAccessorElementImpl).identifier == identifier) {
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
2677 } 2677 }
2678 } 2678 }
2679 // not found 2679 // not found
2680 return false; 2680 return false;
2681 } 2681 }
2682 2682
2683 bool get hasReferenceToSuper => hasModifier(Modifier.REFERENCES_SUPER); 2683 bool get hasReferenceToSuper => hasModifier(Modifier.REFERENCES_SUPER);
2684 2684
2685 bool get isAbstract => hasModifier(Modifier.ABSTRACT); 2685 bool get isAbstract => hasModifier(Modifier.ABSTRACT);
2686 2686
2687 bool get isOrInheritsProxy => safeIsOrInheritsProxy(this, new Set<ClassElement >()); 2687 bool get isOrInheritsProxy => _safeIsOrInheritsProxy(this, new Set<ClassElemen t>());
2688 2688
2689 bool get isProxy { 2689 bool get isProxy {
2690 for (ElementAnnotation annotation in metadata) { 2690 for (ElementAnnotation annotation in metadata) {
2691 if (annotation.isProxy) { 2691 if (annotation.isProxy) {
2692 return true; 2692 return true;
2693 } 2693 }
2694 } 2694 }
2695 return false; 2695 return false;
2696 } 2696 }
2697 2697
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
2911 for (int i = 0; i < variableCount; i++) { 2911 for (int i = 0; i < variableCount; i++) {
2912 if (i > 0) { 2912 if (i > 0) {
2913 builder.append(", "); 2913 builder.append(", ");
2914 } 2914 }
2915 (_typeParameters[i] as TypeParameterElementImpl).appendTo(builder); 2915 (_typeParameters[i] as TypeParameterElementImpl).appendTo(builder);
2916 } 2916 }
2917 builder.append(">"); 2917 builder.append(">");
2918 } 2918 }
2919 } 2919 }
2920 2920
2921 void collectAllSupertypes(List<InterfaceType> supertypes) { 2921 void _collectAllSupertypes(List<InterfaceType> supertypes) {
2922 List<InterfaceType> typesToVisit = new List<InterfaceType>(); 2922 List<InterfaceType> typesToVisit = new List<InterfaceType>();
2923 List<ClassElement> visitedClasses = new List<ClassElement>(); 2923 List<ClassElement> visitedClasses = new List<ClassElement>();
2924 typesToVisit.add(this.type); 2924 typesToVisit.add(this.type);
2925 while (!typesToVisit.isEmpty) { 2925 while (!typesToVisit.isEmpty) {
2926 InterfaceType currentType = typesToVisit.removeAt(0); 2926 InterfaceType currentType = typesToVisit.removeAt(0);
2927 ClassElement currentElement = currentType.element; 2927 ClassElement currentElement = currentType.element;
2928 if (!visitedClasses.contains(currentElement)) { 2928 if (!visitedClasses.contains(currentElement)) {
2929 visitedClasses.add(currentElement); 2929 visitedClasses.add(currentElement);
2930 if (currentType != this.type) { 2930 if (currentType != this.type) {
2931 supertypes.add(currentType); 2931 supertypes.add(currentType);
2932 } 2932 }
2933 InterfaceType supertype = currentType.superclass; 2933 InterfaceType supertype = currentType.superclass;
2934 if (supertype != null) { 2934 if (supertype != null) {
2935 typesToVisit.add(supertype); 2935 typesToVisit.add(supertype);
2936 } 2936 }
2937 for (InterfaceType type in currentElement.interfaces) { 2937 for (InterfaceType type in currentElement.interfaces) {
2938 typesToVisit.add(type); 2938 typesToVisit.add(type);
2939 } 2939 }
2940 for (InterfaceType type in currentElement.mixins) { 2940 for (InterfaceType type in currentElement.mixins) {
2941 ClassElement element = type.element; 2941 ClassElement element = type.element;
2942 if (!visitedClasses.contains(element)) { 2942 if (!visitedClasses.contains(element)) {
2943 supertypes.add(type); 2943 supertypes.add(type);
2944 } 2944 }
2945 } 2945 }
2946 } 2946 }
2947 } 2947 }
2948 } 2948 }
2949 2949
2950 bool safeIsOrInheritsProxy(ClassElement classElt, Set<ClassElement> visitedCla ssElts) { 2950 bool _safeIsOrInheritsProxy(ClassElement classElt, Set<ClassElement> visitedCl assElts) {
2951 if (visitedClassElts.contains(classElt)) { 2951 if (visitedClassElts.contains(classElt)) {
2952 return false; 2952 return false;
2953 } 2953 }
2954 visitedClassElts.add(classElt); 2954 visitedClassElts.add(classElt);
2955 if (classElt.isProxy) { 2955 if (classElt.isProxy) {
2956 return true; 2956 return true;
2957 } else if (classElt.supertype != null && safeIsOrInheritsProxy(classElt.supe rtype.element, visitedClassElts)) { 2957 } else if (classElt.supertype != null && _safeIsOrInheritsProxy(classElt.sup ertype.element, visitedClassElts)) {
2958 return true; 2958 return true;
2959 } 2959 }
2960 List<InterfaceType> supertypes = classElt.interfaces; 2960 List<InterfaceType> supertypes = classElt.interfaces;
2961 for (int i = 0; i < supertypes.length; i++) { 2961 for (int i = 0; i < supertypes.length; i++) {
2962 if (safeIsOrInheritsProxy(supertypes[i].element, visitedClassElts)) { 2962 if (_safeIsOrInheritsProxy(supertypes[i].element, visitedClassElts)) {
2963 return true; 2963 return true;
2964 } 2964 }
2965 } 2965 }
2966 supertypes = classElt.mixins; 2966 supertypes = classElt.mixins;
2967 for (int i = 0; i < supertypes.length; i++) { 2967 for (int i = 0; i < supertypes.length; i++) {
2968 if (safeIsOrInheritsProxy(supertypes[i].element, visitedClassElts)) { 2968 if (_safeIsOrInheritsProxy(supertypes[i].element, visitedClassElts)) {
2969 return true; 2969 return true;
2970 } 2970 }
2971 } 2971 }
2972 return false; 2972 return false;
2973 } 2973 }
2974 } 2974 }
2975 2975
2976 /** 2976 /**
2977 * Instances of the class `CompilationUnitElementImpl` implement a 2977 * Instances of the class `CompilationUnitElementImpl` implement a
2978 * [CompilationUnitElement]. 2978 * [CompilationUnitElement].
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
3195 } 3195 }
3196 3196
3197 String get identifier => source.encoding; 3197 String get identifier => source.encoding;
3198 3198
3199 /** 3199 /**
3200 * Returns the associated toolkit objects. 3200 * Returns the associated toolkit objects.
3201 * 3201 *
3202 * @param element the [Element] to get toolkit objects for 3202 * @param element the [Element] to get toolkit objects for
3203 * @return the associated toolkit objects, may be empty, but not `null` 3203 * @return the associated toolkit objects, may be empty, but not `null`
3204 */ 3204 */
3205 List<ToolkitObjectElement> getToolkitObjects(Element element) { 3205 List<ToolkitObjectElement> _getToolkitObjects(Element element) {
3206 List<ToolkitObjectElement> objects = _toolkitObjects[element]; 3206 List<ToolkitObjectElement> objects = _toolkitObjects[element];
3207 if (objects != null) { 3207 if (objects != null) {
3208 return objects; 3208 return objects;
3209 } 3209 }
3210 return ToolkitObjectElement.EMPTY_ARRAY; 3210 return ToolkitObjectElement.EMPTY_ARRAY;
3211 } 3211 }
3212 3212
3213 /** 3213 /**
3214 * Sets the toolkit objects that are associated with the given [Element]. 3214 * Sets the toolkit objects that are associated with the given [Element].
3215 * 3215 *
3216 * @param element the [Element] to associate toolkit objects with 3216 * @param element the [Element] to associate toolkit objects with
3217 * @param objects the toolkit objects to associate 3217 * @param objects the toolkit objects to associate
3218 */ 3218 */
3219 void setToolkitObjects(Element element, List<ToolkitObjectElement> objects) { 3219 void _setToolkitObjects(Element element, List<ToolkitObjectElement> objects) {
3220 _toolkitObjects[element] = objects; 3220 _toolkitObjects[element] = objects;
3221 } 3221 }
3222 } 3222 }
3223 3223
3224 /** 3224 /**
3225 * Instances of the class `ConstFieldElementImpl` implement a `FieldElement` for a 3225 * Instances of the class `ConstFieldElementImpl` implement a `FieldElement` for a
3226 * 'const' field that has an initializer. 3226 * 'const' field that has an initializer.
3227 */ 3227 */
3228 class ConstFieldElementImpl extends FieldElementImpl { 3228 class ConstFieldElementImpl extends FieldElementImpl {
3229 /** 3229 /**
(...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after
3861 } 3861 }
3862 this._components = new List.from(components); 3862 this._components = new List.from(components);
3863 } 3863 }
3864 3864
3865 /** 3865 /**
3866 * Initialize a newly created location from the given encoded form. 3866 * Initialize a newly created location from the given encoded form.
3867 * 3867 *
3868 * @param encoding the encoded form of a location 3868 * @param encoding the encoded form of a location
3869 */ 3869 */
3870 ElementLocationImpl.con2(String encoding) { 3870 ElementLocationImpl.con2(String encoding) {
3871 this._components = decode(encoding); 3871 this._components = _decode(encoding);
3872 } 3872 }
3873 3873
3874 bool operator ==(Object object) { 3874 bool operator ==(Object object) {
3875 if (identical(this, object)) { 3875 if (identical(this, object)) {
3876 return true; 3876 return true;
3877 } 3877 }
3878 if (object is! ElementLocationImpl) { 3878 if (object is! ElementLocationImpl) {
3879 return false; 3879 return false;
3880 } 3880 }
3881 ElementLocationImpl location = object as ElementLocationImpl; 3881 ElementLocationImpl location = object as ElementLocationImpl;
3882 List<String> otherComponents = location._components; 3882 List<String> otherComponents = location._components;
3883 int length = _components.length; 3883 int length = _components.length;
3884 if (otherComponents.length != length) { 3884 if (otherComponents.length != length) {
3885 return false; 3885 return false;
3886 } 3886 }
3887 for (int i = length - 1; i >= 2; i--) { 3887 for (int i = length - 1; i >= 2; i--) {
3888 if (_components[i] != otherComponents[i]) { 3888 if (_components[i] != otherComponents[i]) {
3889 return false; 3889 return false;
3890 } 3890 }
3891 } 3891 }
3892 if (length > 1 && !equalSourceComponents(_components[1], otherComponents[1]) ) { 3892 if (length > 1 && !_equalSourceComponents(_components[1], otherComponents[1] )) {
3893 return false; 3893 return false;
3894 } 3894 }
3895 if (length > 0 && !equalSourceComponents(_components[0], otherComponents[0]) ) { 3895 if (length > 0 && !_equalSourceComponents(_components[0], otherComponents[0] )) {
3896 return false; 3896 return false;
3897 } 3897 }
3898 return true; 3898 return true;
3899 } 3899 }
3900 3900
3901 /** 3901 /**
3902 * Return the path to the element whose location is represented by this object . 3902 * Return the path to the element whose location is represented by this object .
3903 * 3903 *
3904 * @return the path to the element whose location is represented by this objec t 3904 * @return the path to the element whose location is represented by this objec t
3905 */ 3905 */
3906 List<String> get components => _components; 3906 List<String> get components => _components;
3907 3907
3908 String get encoding { 3908 String get encoding {
3909 JavaStringBuilder builder = new JavaStringBuilder(); 3909 JavaStringBuilder builder = new JavaStringBuilder();
3910 int length = _components.length; 3910 int length = _components.length;
3911 for (int i = 0; i < length; i++) { 3911 for (int i = 0; i < length; i++) {
3912 if (i > 0) { 3912 if (i > 0) {
3913 builder.appendChar(_SEPARATOR_CHAR); 3913 builder.appendChar(_SEPARATOR_CHAR);
3914 } 3914 }
3915 encode(builder, _components[i]); 3915 _encode(builder, _components[i]);
3916 } 3916 }
3917 return builder.toString(); 3917 return builder.toString();
3918 } 3918 }
3919 3919
3920 int get hashCode { 3920 int get hashCode {
3921 int result = 1; 3921 int result = 1;
3922 for (int i = 0; i < _components.length; i++) { 3922 for (int i = 0; i < _components.length; i++) {
3923 String component = _components[i]; 3923 String component = _components[i];
3924 int componentHash; 3924 int componentHash;
3925 if (i <= 1) { 3925 if (i <= 1) {
3926 componentHash = hashSourceComponent(component); 3926 componentHash = _hashSourceComponent(component);
3927 } else { 3927 } else {
3928 componentHash = component.hashCode; 3928 componentHash = component.hashCode;
3929 } 3929 }
3930 result = 31 * result + componentHash; 3930 result = 31 * result + componentHash;
3931 } 3931 }
3932 return result; 3932 return result;
3933 } 3933 }
3934 3934
3935 String toString() => encoding; 3935 String toString() => encoding;
3936 3936
3937 /** 3937 /**
3938 * Decode the encoded form of a location into an array of components. 3938 * Decode the encoded form of a location into an array of components.
3939 * 3939 *
3940 * @param encoding the encoded form of a location 3940 * @param encoding the encoded form of a location
3941 * @return the components that were encoded 3941 * @return the components that were encoded
3942 */ 3942 */
3943 List<String> decode(String encoding) { 3943 List<String> _decode(String encoding) {
3944 List<String> components = new List<String>(); 3944 List<String> components = new List<String>();
3945 JavaStringBuilder builder = new JavaStringBuilder(); 3945 JavaStringBuilder builder = new JavaStringBuilder();
3946 int index = 0; 3946 int index = 0;
3947 int length = encoding.length; 3947 int length = encoding.length;
3948 while (index < length) { 3948 while (index < length) {
3949 int currentChar = encoding.codeUnitAt(index); 3949 int currentChar = encoding.codeUnitAt(index);
3950 if (currentChar == _SEPARATOR_CHAR) { 3950 if (currentChar == _SEPARATOR_CHAR) {
3951 if (index + 1 < length && encoding.codeUnitAt(index + 1) == _SEPARATOR_C HAR) { 3951 if (index + 1 < length && encoding.codeUnitAt(index + 1) == _SEPARATOR_C HAR) {
3952 builder.appendChar(_SEPARATOR_CHAR); 3952 builder.appendChar(_SEPARATOR_CHAR);
3953 index += 2; 3953 index += 2;
(...skipping 12 matching lines...) Expand all
3966 } 3966 }
3967 return new List.from(components); 3967 return new List.from(components);
3968 } 3968 }
3969 3969
3970 /** 3970 /**
3971 * Append an encoded form of the given component to the given builder. 3971 * Append an encoded form of the given component to the given builder.
3972 * 3972 *
3973 * @param builder the builder to which the encoded component is to be appended 3973 * @param builder the builder to which the encoded component is to be appended
3974 * @param component the component to be appended to the builder 3974 * @param component the component to be appended to the builder
3975 */ 3975 */
3976 void encode(JavaStringBuilder builder, String component) { 3976 void _encode(JavaStringBuilder builder, String component) {
3977 int length = component.length; 3977 int length = component.length;
3978 for (int i = 0; i < length; i++) { 3978 for (int i = 0; i < length; i++) {
3979 int currentChar = component.codeUnitAt(i); 3979 int currentChar = component.codeUnitAt(i);
3980 if (currentChar == _SEPARATOR_CHAR) { 3980 if (currentChar == _SEPARATOR_CHAR) {
3981 builder.appendChar(_SEPARATOR_CHAR); 3981 builder.appendChar(_SEPARATOR_CHAR);
3982 } 3982 }
3983 builder.appendChar(currentChar); 3983 builder.appendChar(currentChar);
3984 } 3984 }
3985 } 3985 }
3986 3986
3987 /** 3987 /**
3988 * Return `true` if the given components, when interpreted to be encoded sourc es with a 3988 * Return `true` if the given components, when interpreted to be encoded sourc es with a
3989 * leading source type indicator, are equal when the source type's are ignored . 3989 * leading source type indicator, are equal when the source type's are ignored .
3990 * 3990 *
3991 * @param left the left component being compared 3991 * @param left the left component being compared
3992 * @param right the right component being compared 3992 * @param right the right component being compared
3993 * @return `true` if the given components are equal when the source type's are ignored 3993 * @return `true` if the given components are equal when the source type's are ignored
3994 */ 3994 */
3995 bool equalSourceComponents(String left, String right) { 3995 bool _equalSourceComponents(String left, String right) {
3996 // TODO(brianwilkerson) This method can go away when sources no longer have a URI kind. 3996 // TODO(brianwilkerson) This method can go away when sources no longer have a URI kind.
3997 if (left == null) { 3997 if (left == null) {
3998 return right == null; 3998 return right == null;
3999 } else if (right == null) { 3999 } else if (right == null) {
4000 return false; 4000 return false;
4001 } 4001 }
4002 int leftLength = left.length; 4002 int leftLength = left.length;
4003 int rightLength = right.length; 4003 int rightLength = right.length;
4004 if (leftLength != rightLength) { 4004 if (leftLength != rightLength) {
4005 return false; 4005 return false;
4006 } else if (leftLength <= 1 || rightLength <= 1) { 4006 } else if (leftLength <= 1 || rightLength <= 1) {
4007 return left == right; 4007 return left == right;
4008 } 4008 }
4009 return javaStringRegionMatches(left, 1, right, 1, leftLength - 1); 4009 return javaStringRegionMatches(left, 1, right, 1, leftLength - 1);
4010 } 4010 }
4011 4011
4012 /** 4012 /**
4013 * Return the hash code of the given encoded source component, ignoring the so urce type indicator. 4013 * Return the hash code of the given encoded source component, ignoring the so urce type indicator.
4014 * 4014 *
4015 * @param sourceComponent the component to compute a hash code 4015 * @param sourceComponent the component to compute a hash code
4016 * @return the hash code of the given encoded source component 4016 * @return the hash code of the given encoded source component
4017 */ 4017 */
4018 int hashSourceComponent(String sourceComponent) { 4018 int _hashSourceComponent(String sourceComponent) {
4019 // TODO(brianwilkerson) This method can go away when sources no longer have a URI kind. 4019 // TODO(brianwilkerson) This method can go away when sources no longer have a URI kind.
4020 if (sourceComponent.length <= 1) { 4020 if (sourceComponent.length <= 1) {
4021 return sourceComponent.hashCode; 4021 return sourceComponent.hashCode;
4022 } 4022 }
4023 return sourceComponent.substring(1).hashCode; 4023 return sourceComponent.substring(1).hashCode;
4024 } 4024 }
4025 } 4025 }
4026 4026
4027 /** 4027 /**
4028 * The class `ElementPair` is a pair of [Element]s. [Object#equals] and 4028 * The class `ElementPair` is a pair of [Element]s. [Object#equals] and
(...skipping 872 matching lines...) Expand 10 before | Expand all | Expand 10 after
4901 */ 4901 */
4902 static List<LibraryElement> EMPTY_ARRAY = new List<LibraryElement>(0); 4902 static List<LibraryElement> EMPTY_ARRAY = new List<LibraryElement>(0);
4903 4903
4904 /** 4904 /**
4905 * Determine if the given library is up to date with respect to the given time stamp. 4905 * Determine if the given library is up to date with respect to the given time stamp.
4906 * 4906 *
4907 * @param library the library to process 4907 * @param library the library to process
4908 * @param timeStamp the time stamp to check against 4908 * @param timeStamp the time stamp to check against
4909 * @param visitedLibraries the set of visited libraries 4909 * @param visitedLibraries the set of visited libraries
4910 */ 4910 */
4911 static bool safeIsUpToDate(LibraryElement library, int timeStamp, Set<LibraryE lement> visitedLibraries) { 4911 static bool _safeIsUpToDate(LibraryElement library, int timeStamp, Set<Library Element> visitedLibraries) {
4912 if (!visitedLibraries.contains(library)) { 4912 if (!visitedLibraries.contains(library)) {
4913 visitedLibraries.add(library); 4913 visitedLibraries.add(library);
4914 AnalysisContext context = library.context; 4914 AnalysisContext context = library.context;
4915 // Check the defining compilation unit. 4915 // Check the defining compilation unit.
4916 if (timeStamp < context.getModificationStamp(library.definingCompilationUn it.source)) { 4916 if (timeStamp < context.getModificationStamp(library.definingCompilationUn it.source)) {
4917 return false; 4917 return false;
4918 } 4918 }
4919 // Check the parted compilation units. 4919 // Check the parted compilation units.
4920 for (CompilationUnitElement element in library.parts) { 4920 for (CompilationUnitElement element in library.parts) {
4921 if (timeStamp < context.getModificationStamp(element.source)) { 4921 if (timeStamp < context.getModificationStamp(element.source)) {
4922 return false; 4922 return false;
4923 } 4923 }
4924 } 4924 }
4925 // Check the imported libraries. 4925 // Check the imported libraries.
4926 for (LibraryElement importedLibrary in library.importedLibraries) { 4926 for (LibraryElement importedLibrary in library.importedLibraries) {
4927 if (!safeIsUpToDate(importedLibrary, timeStamp, visitedLibraries)) { 4927 if (!_safeIsUpToDate(importedLibrary, timeStamp, visitedLibraries)) {
4928 return false; 4928 return false;
4929 } 4929 }
4930 } 4930 }
4931 // Check the exported libraries. 4931 // Check the exported libraries.
4932 for (LibraryElement exportedLibrary in library.exportedLibraries) { 4932 for (LibraryElement exportedLibrary in library.exportedLibraries) {
4933 if (!safeIsUpToDate(exportedLibrary, timeStamp, visitedLibraries)) { 4933 if (!_safeIsUpToDate(exportedLibrary, timeStamp, visitedLibraries)) {
4934 return false; 4934 return false;
4935 } 4935 }
4936 } 4936 }
4937 } 4937 }
4938 return true; 4938 return true;
4939 } 4939 }
4940 4940
4941 /** 4941 /**
4942 * The analysis context in which this library is defined. 4942 * The analysis context in which this library is defined.
4943 */ 4943 */
(...skipping 21 matching lines...) Expand all
4965 4965
4966 /** 4966 /**
4967 * An array containing all of the compilation units that are included in this library using a 4967 * An array containing all of the compilation units that are included in this library using a
4968 * `part` directive. 4968 * `part` directive.
4969 */ 4969 */
4970 List<CompilationUnitElement> _parts = CompilationUnitElementImpl.EMPTY_ARRAY; 4970 List<CompilationUnitElement> _parts = CompilationUnitElementImpl.EMPTY_ARRAY;
4971 4971
4972 /** 4972 /**
4973 * Is `true` if this library is created for Angular analysis. 4973 * Is `true` if this library is created for Angular analysis.
4974 */ 4974 */
4975 bool _isAngularHtml2 = false; 4975 bool _isAngularHtml = false;
4976 4976
4977 /** 4977 /**
4978 * Initialize a newly created library element to have the given name. 4978 * Initialize a newly created library element to have the given name.
4979 * 4979 *
4980 * @param context the analysis context in which the library is defined 4980 * @param context the analysis context in which the library is defined
4981 * @param name the name of this element 4981 * @param name the name of this element
4982 */ 4982 */
4983 LibraryElementImpl(this.context, LibraryIdentifier name) : super.con1(name); 4983 LibraryElementImpl(this.context, LibraryIdentifier name) : super.con1(name);
4984 4984
4985 accept(ElementVisitor visitor) => visitor.visitLibraryElement(this); 4985 accept(ElementVisitor visitor) => visitor.visitLibraryElement(this);
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
5076 5076
5077 List<CompilationUnitElement> get units { 5077 List<CompilationUnitElement> get units {
5078 List<CompilationUnitElement> units = new List<CompilationUnitElement>(1 + _p arts.length); 5078 List<CompilationUnitElement> units = new List<CompilationUnitElement>(1 + _p arts.length);
5079 units[0] = _definingCompilationUnit; 5079 units[0] = _definingCompilationUnit;
5080 JavaSystem.arraycopy(_parts, 0, units, 1, _parts.length); 5080 JavaSystem.arraycopy(_parts, 0, units, 1, _parts.length);
5081 return units; 5081 return units;
5082 } 5082 }
5083 5083
5084 List<LibraryElement> get visibleLibraries { 5084 List<LibraryElement> get visibleLibraries {
5085 Set<LibraryElement> visibleLibraries = new Set(); 5085 Set<LibraryElement> visibleLibraries = new Set();
5086 addVisibleLibraries(visibleLibraries, false); 5086 _addVisibleLibraries(visibleLibraries, false);
5087 return new List.from(visibleLibraries); 5087 return new List.from(visibleLibraries);
5088 } 5088 }
5089 5089
5090 bool get hasExtUri => hasModifier(Modifier.HAS_EXT_URI); 5090 bool get hasExtUri => hasModifier(Modifier.HAS_EXT_URI);
5091 5091
5092 int get hashCode => _definingCompilationUnit.hashCode; 5092 int get hashCode => _definingCompilationUnit.hashCode;
5093 5093
5094 bool get isAngularHtml => _isAngularHtml2; 5094 bool get isAngularHtml => _isAngularHtml;
5095 5095
5096 bool get isBrowserApplication => entryPoint != null && isOrImportsBrowserLibra ry; 5096 bool get isBrowserApplication => entryPoint != null && isOrImportsBrowserLibra ry;
5097 5097
5098 bool get isDartCore => name == "dart.core"; 5098 bool get isDartCore => name == "dart.core";
5099 5099
5100 bool get isInSdk => StringUtilities.startsWith5(name, 0, 0x64, 0x61, 0x72, 0x7 4, 0x2E); 5100 bool get isInSdk => StringUtilities.startsWith5(name, 0, 0x64, 0x61, 0x72, 0x7 4, 0x2E);
5101 5101
5102 bool isUpToDate(int timeStamp) { 5102 bool isUpToDate(int timeStamp) {
5103 Set<LibraryElement> visitedLibraries = new Set(); 5103 Set<LibraryElement> visitedLibraries = new Set();
5104 return safeIsUpToDate(this, timeStamp, visitedLibraries); 5104 return _safeIsUpToDate(this, timeStamp, visitedLibraries);
5105 } 5105 }
5106 5106
5107 /** 5107 /**
5108 * Specifies if this library is created for Angular analysis. 5108 * Specifies if this library is created for Angular analysis.
5109 */ 5109 */
5110 void set angularHtml(bool isAngularHtml) { 5110 void set angularHtml(bool isAngularHtml) {
5111 this._isAngularHtml2 = isAngularHtml; 5111 this._isAngularHtml = isAngularHtml;
5112 } 5112 }
5113 5113
5114 /** 5114 /**
5115 * Set the compilation unit that defines this library to the given compilation unit. 5115 * Set the compilation unit that defines this library to the given compilation unit.
5116 * 5116 *
5117 * @param definingCompilationUnit the compilation unit that defines this libra ry 5117 * @param definingCompilationUnit the compilation unit that defines this libra ry
5118 */ 5118 */
5119 void set definingCompilationUnit(CompilationUnitElement definingCompilationUni t) { 5119 void set definingCompilationUnit(CompilationUnitElement definingCompilationUni t) {
5120 (definingCompilationUnit as CompilationUnitElementImpl).enclosingElement = t his; 5120 (definingCompilationUnit as CompilationUnitElementImpl).enclosingElement = t his;
5121 this._definingCompilationUnit = definingCompilationUnit; 5121 this._definingCompilationUnit = definingCompilationUnit;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
5177 safelyVisitChildren(_exports, visitor); 5177 safelyVisitChildren(_exports, visitor);
5178 safelyVisitChildren(_imports, visitor); 5178 safelyVisitChildren(_imports, visitor);
5179 safelyVisitChildren(_parts, visitor); 5179 safelyVisitChildren(_parts, visitor);
5180 } 5180 }
5181 5181
5182 String get identifier => _definingCompilationUnit.source.encoding; 5182 String get identifier => _definingCompilationUnit.source.encoding;
5183 5183
5184 /** 5184 /**
5185 * Recursively fills set of visible libraries for [getVisibleElementsLibraries ]. 5185 * Recursively fills set of visible libraries for [getVisibleElementsLibraries ].
5186 */ 5186 */
5187 void addVisibleLibraries(Set<LibraryElement> visibleLibraries, bool includeExp orts) { 5187 void _addVisibleLibraries(Set<LibraryElement> visibleLibraries, bool includeEx ports) {
5188 // maybe already processed 5188 // maybe already processed
5189 if (!visibleLibraries.add(this)) { 5189 if (!visibleLibraries.add(this)) {
5190 return; 5190 return;
5191 } 5191 }
5192 // add imported libraries 5192 // add imported libraries
5193 for (ImportElement importElement in _imports) { 5193 for (ImportElement importElement in _imports) {
5194 LibraryElement importedLibrary = importElement.importedLibrary; 5194 LibraryElement importedLibrary = importElement.importedLibrary;
5195 if (importedLibrary != null) { 5195 if (importedLibrary != null) {
5196 (importedLibrary as LibraryElementImpl).addVisibleLibraries(visibleLibra ries, true); 5196 (importedLibrary as LibraryElementImpl)._addVisibleLibraries(visibleLibr aries, true);
5197 } 5197 }
5198 } 5198 }
5199 // add exported libraries 5199 // add exported libraries
5200 if (includeExports) { 5200 if (includeExports) {
5201 for (ExportElement exportElement in _exports) { 5201 for (ExportElement exportElement in _exports) {
5202 LibraryElement exportedLibrary = exportElement.exportedLibrary; 5202 LibraryElement exportedLibrary = exportElement.exportedLibrary;
5203 if (exportedLibrary != null) { 5203 if (exportedLibrary != null) {
5204 (exportedLibrary as LibraryElementImpl).addVisibleLibraries(visibleLib raries, true); 5204 (exportedLibrary as LibraryElementImpl)._addVisibleLibraries(visibleLi braries, true);
5205 } 5205 }
5206 } 5206 }
5207 } 5207 }
5208 } 5208 }
5209 5209
5210 /** 5210 /**
5211 * Answer `true` if the receiver directly or indirectly imports the dart:html libraries. 5211 * Answer `true` if the receiver directly or indirectly imports the dart:html libraries.
5212 * 5212 *
5213 * @return `true` if the receiver directly or indirectly imports the dart:html libraries 5213 * @return `true` if the receiver directly or indirectly imports the dart:html libraries
5214 */ 5214 */
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
5276 5276
5277 accept(ElementVisitor visitor) => visitor.visitLocalVariableElement(this); 5277 accept(ElementVisitor visitor) => visitor.visitLocalVariableElement(this);
5278 5278
5279 ElementKind get kind => ElementKind.LOCAL_VARIABLE; 5279 ElementKind get kind => ElementKind.LOCAL_VARIABLE;
5280 5280
5281 List<ToolkitObjectElement> get toolkitObjects { 5281 List<ToolkitObjectElement> get toolkitObjects {
5282 CompilationUnitElementImpl unit = getAncestor((element) => element is Compil ationUnitElementImpl); 5282 CompilationUnitElementImpl unit = getAncestor((element) => element is Compil ationUnitElementImpl);
5283 if (unit == null) { 5283 if (unit == null) {
5284 return ToolkitObjectElement.EMPTY_ARRAY; 5284 return ToolkitObjectElement.EMPTY_ARRAY;
5285 } 5285 }
5286 return unit.getToolkitObjects(this); 5286 return unit._getToolkitObjects(this);
5287 } 5287 }
5288 5288
5289 SourceRange get visibleRange { 5289 SourceRange get visibleRange {
5290 if (_visibleRangeLength < 0) { 5290 if (_visibleRangeLength < 0) {
5291 return null; 5291 return null;
5292 } 5292 }
5293 return new SourceRange(_visibleRangeOffset, _visibleRangeLength); 5293 return new SourceRange(_visibleRangeOffset, _visibleRangeLength);
5294 } 5294 }
5295 5295
5296 bool get isPotentiallyMutatedInClosure => _potentiallyMutatedInClosure; 5296 bool get isPotentiallyMutatedInClosure => _potentiallyMutatedInClosure;
(...skipping 17 matching lines...) Expand all
5314 /** 5314 /**
5315 * Set the toolkit specific information objects attached to this variable. 5315 * Set the toolkit specific information objects attached to this variable.
5316 * 5316 *
5317 * @param toolkitObjects the toolkit objects attached to this variable 5317 * @param toolkitObjects the toolkit objects attached to this variable
5318 */ 5318 */
5319 void set toolkitObjects(List<ToolkitObjectElement> toolkitObjects) { 5319 void set toolkitObjects(List<ToolkitObjectElement> toolkitObjects) {
5320 CompilationUnitElementImpl unit = getAncestor((element) => element is Compil ationUnitElementImpl); 5320 CompilationUnitElementImpl unit = getAncestor((element) => element is Compil ationUnitElementImpl);
5321 if (unit == null) { 5321 if (unit == null) {
5322 return; 5322 return;
5323 } 5323 }
5324 unit.setToolkitObjects(this, toolkitObjects); 5324 unit._setToolkitObjects(this, toolkitObjects);
5325 } 5325 }
5326 5326
5327 /** 5327 /**
5328 * Set the visible range for this element to the range starting at the given o ffset with the given 5328 * Set the visible range for this element to the range starting at the given o ffset with the given
5329 * length. 5329 * length.
5330 * 5330 *
5331 * @param offset the offset to the beginning of the visible range for this ele ment 5331 * @param offset the offset to the beginning of the visible range for this ele ment
5332 * @param length the length of the visible range for this element, or `-1` if this element 5332 * @param length the length of the visible range for this element, or `-1` if this element
5333 * does not have a visible range 5333 * does not have a visible range
5334 */ 5334 */
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
5510 */ 5510 */
5511 class MultiplyDefinedElementImpl implements MultiplyDefinedElement { 5511 class MultiplyDefinedElementImpl implements MultiplyDefinedElement {
5512 /** 5512 /**
5513 * Return an element that represents the given conflicting elements. 5513 * Return an element that represents the given conflicting elements.
5514 * 5514 *
5515 * @param context the analysis context in which the multiply defined elements are defined 5515 * @param context the analysis context in which the multiply defined elements are defined
5516 * @param firstElement the first element that conflicts 5516 * @param firstElement the first element that conflicts
5517 * @param secondElement the second element that conflicts 5517 * @param secondElement the second element that conflicts
5518 */ 5518 */
5519 static Element fromElements(AnalysisContext context, Element firstElement, Ele ment secondElement) { 5519 static Element fromElements(AnalysisContext context, Element firstElement, Ele ment secondElement) {
5520 List<Element> conflictingElements = computeConflictingElements(firstElement, secondElement); 5520 List<Element> conflictingElements = _computeConflictingElements(firstElement , secondElement);
5521 int length = conflictingElements.length; 5521 int length = conflictingElements.length;
5522 if (length == 0) { 5522 if (length == 0) {
5523 return null; 5523 return null;
5524 } else if (length == 1) { 5524 } else if (length == 1) {
5525 return conflictingElements[0]; 5525 return conflictingElements[0];
5526 } 5526 }
5527 return new MultiplyDefinedElementImpl(context, conflictingElements); 5527 return new MultiplyDefinedElementImpl(context, conflictingElements);
5528 } 5528 }
5529 5529
5530 /** 5530 /**
5531 * Add the given element to the list of elements. If the element is a multiply -defined element, 5531 * Add the given element to the list of elements. If the element is a multiply -defined element,
5532 * add all of the conflicting elements that it represents. 5532 * add all of the conflicting elements that it represents.
5533 * 5533 *
5534 * @param elements the list to which the element(s) are to be added 5534 * @param elements the list to which the element(s) are to be added
5535 * @param element the element(s) to be added 5535 * @param element the element(s) to be added
5536 */ 5536 */
5537 static void add(Set<Element> elements, Element element) { 5537 static void _add(Set<Element> elements, Element element) {
5538 if (element is MultiplyDefinedElementImpl) { 5538 if (element is MultiplyDefinedElementImpl) {
5539 for (Element conflictingElement in element.conflictingElements) { 5539 for (Element conflictingElement in element.conflictingElements) {
5540 elements.add(conflictingElement); 5540 elements.add(conflictingElement);
5541 } 5541 }
5542 } else { 5542 } else {
5543 elements.add(element); 5543 elements.add(element);
5544 } 5544 }
5545 } 5545 }
5546 5546
5547 /** 5547 /**
5548 * Use the given elements to construct an array of conflicting elements. If ei ther of the given 5548 * Use the given elements to construct an array of conflicting elements. If ei ther of the given
5549 * elements are multiply-defined elements then the conflicting elements they r epresent will be 5549 * elements are multiply-defined elements then the conflicting elements they r epresent will be
5550 * included in the array. Otherwise, the element itself will be included. 5550 * included in the array. Otherwise, the element itself will be included.
5551 * 5551 *
5552 * @param firstElement the first element to be included 5552 * @param firstElement the first element to be included
5553 * @param secondElement the second element to be included 5553 * @param secondElement the second element to be included
5554 * @return an array containing all of the conflicting elements 5554 * @return an array containing all of the conflicting elements
5555 */ 5555 */
5556 static List<Element> computeConflictingElements(Element firstElement, Element secondElement) { 5556 static List<Element> _computeConflictingElements(Element firstElement, Element secondElement) {
5557 Set<Element> elements = new Set<Element>(); 5557 Set<Element> elements = new Set<Element>();
5558 add(elements, firstElement); 5558 _add(elements, firstElement);
5559 add(elements, secondElement); 5559 _add(elements, secondElement);
5560 return new List.from(elements); 5560 return new List.from(elements);
5561 } 5561 }
5562 5562
5563 /** 5563 /**
5564 * The analysis context in which the multiply defined elements are defined. 5564 * The analysis context in which the multiply defined elements are defined.
5565 */ 5565 */
5566 final AnalysisContext context; 5566 final AnalysisContext context;
5567 5567
5568 /** 5568 /**
5569 * The name of the conflicting elements. 5569 * The name of the conflicting elements.
(...skipping 2027 matching lines...) Expand 10 before | Expand all | Expand 10 after
7597 * Return `true` if all of the name/type pairs in the first map are equal to t he 7597 * Return `true` if all of the name/type pairs in the first map are equal to t he
7598 * corresponding name/type pairs in the second map. The maps are expected to i terate over their 7598 * corresponding name/type pairs in the second map. The maps are expected to i terate over their
7599 * entries in the same order in which those entries were added to the map. 7599 * entries in the same order in which those entries were added to the map.
7600 * 7600 *
7601 * @param firstTypes the first map of name/type pairs being compared 7601 * @param firstTypes the first map of name/type pairs being compared
7602 * @param secondTypes the second map of name/type pairs being compared 7602 * @param secondTypes the second map of name/type pairs being compared
7603 * @param visitedElementPairs a set of visited element pairs 7603 * @param visitedElementPairs a set of visited element pairs
7604 * @return `true` if all of the name/type pairs in the first map are equal to the 7604 * @return `true` if all of the name/type pairs in the first map are equal to the
7605 * corresponding name/type pairs in the second map 7605 * corresponding name/type pairs in the second map
7606 */ 7606 */
7607 static bool equals2(Map<String, Type2> firstTypes, Map<String, Type2> secondTy pes, Set<ElementPair> visitedElementPairs) { 7607 static bool _equals(Map<String, Type2> firstTypes, Map<String, Type2> secondTy pes, Set<ElementPair> visitedElementPairs) {
7608 if (secondTypes.length != firstTypes.length) { 7608 if (secondTypes.length != firstTypes.length) {
7609 return false; 7609 return false;
7610 } 7610 }
7611 JavaIterator<MapEntry<String, Type2>> firstIterator = new JavaIterator(getMa pEntrySet(firstTypes)); 7611 JavaIterator<MapEntry<String, Type2>> firstIterator = new JavaIterator(getMa pEntrySet(firstTypes));
7612 JavaIterator<MapEntry<String, Type2>> secondIterator = new JavaIterator(getM apEntrySet(secondTypes)); 7612 JavaIterator<MapEntry<String, Type2>> secondIterator = new JavaIterator(getM apEntrySet(secondTypes));
7613 while (firstIterator.hasNext) { 7613 while (firstIterator.hasNext) {
7614 MapEntry<String, Type2> firstEntry = firstIterator.next(); 7614 MapEntry<String, Type2> firstEntry = firstIterator.next();
7615 MapEntry<String, Type2> secondEntry = secondIterator.next(); 7615 MapEntry<String, Type2> secondEntry = secondIterator.next();
7616 if (firstEntry.getKey() != secondEntry.getKey() || !(firstEntry.getValue() as TypeImpl).internalEquals(secondEntry.getValue(), visitedElementPairs)) { 7616 if (firstEntry.getKey() != secondEntry.getKey() || !(firstEntry.getValue() as TypeImpl).internalEquals(secondEntry.getValue(), visitedElementPairs)) {
7617 return false; 7617 return false;
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
7838 return false; 7838 return false;
7839 } 7839 }
7840 // named parameters case 7840 // named parameters case
7841 if (t.namedParameterTypes.length > 0) { 7841 if (t.namedParameterTypes.length > 0) {
7842 // check that the number of required parameters are equal, and check that every t_i is 7842 // check that the number of required parameters are equal, and check that every t_i is
7843 // more specific than every s_i 7843 // more specific than every s_i
7844 if (t.normalParameterTypes.length != s.normalParameterTypes.length) { 7844 if (t.normalParameterTypes.length != s.normalParameterTypes.length) {
7845 return false; 7845 return false;
7846 } else if (t.normalParameterTypes.length > 0) { 7846 } else if (t.normalParameterTypes.length > 0) {
7847 for (int i = 0; i < tTypes.length; i++) { 7847 for (int i = 0; i < tTypes.length; i++) {
7848 if (!(tTypes[i] as TypeImpl).isMoreSpecificThan3(sTypes[i], withDynami c, visitedTypePairs)) { 7848 if (!(tTypes[i] as TypeImpl).isMoreSpecificThan2(sTypes[i], withDynami c, visitedTypePairs)) {
7849 return false; 7849 return false;
7850 } 7850 }
7851 } 7851 }
7852 } 7852 }
7853 Map<String, Type2> namedTypesT = t.namedParameterTypes; 7853 Map<String, Type2> namedTypesT = t.namedParameterTypes;
7854 Map<String, Type2> namedTypesS = s.namedParameterTypes; 7854 Map<String, Type2> namedTypesS = s.namedParameterTypes;
7855 // if k >= m is false, return false: the passed function type has more nam ed parameter types than this 7855 // if k >= m is false, return false: the passed function type has more nam ed parameter types than this
7856 if (namedTypesT.length < namedTypesS.length) { 7856 if (namedTypesT.length < namedTypesS.length) {
7857 return false; 7857 return false;
7858 } 7858 }
7859 // Loop through each element in S verifying that T has a matching paramete r name and that the 7859 // Loop through each element in S verifying that T has a matching paramete r name and that the
7860 // corresponding type is more specific then the type in S. 7860 // corresponding type is more specific then the type in S.
7861 JavaIterator<MapEntry<String, Type2>> iteratorS = new JavaIterator(getMapE ntrySet(namedTypesS)); 7861 JavaIterator<MapEntry<String, Type2>> iteratorS = new JavaIterator(getMapE ntrySet(namedTypesS));
7862 while (iteratorS.hasNext) { 7862 while (iteratorS.hasNext) {
7863 MapEntry<String, Type2> entryS = iteratorS.next(); 7863 MapEntry<String, Type2> entryS = iteratorS.next();
7864 Type2 typeT = namedTypesT[entryS.getKey()]; 7864 Type2 typeT = namedTypesT[entryS.getKey()];
7865 if (typeT == null) { 7865 if (typeT == null) {
7866 return false; 7866 return false;
7867 } 7867 }
7868 if (!(typeT as TypeImpl).isMoreSpecificThan3(entryS.getValue(), withDyna mic, visitedTypePairs)) { 7868 if (!(typeT as TypeImpl).isMoreSpecificThan2(entryS.getValue(), withDyna mic, visitedTypePairs)) {
7869 return false; 7869 return false;
7870 } 7870 }
7871 } 7871 }
7872 } else if (s.namedParameterTypes.length > 0) { 7872 } else if (s.namedParameterTypes.length > 0) {
7873 return false; 7873 return false;
7874 } else { 7874 } else {
7875 // positional parameter case 7875 // positional parameter case
7876 int tArgLength = tTypes.length + tOpTypes.length; 7876 int tArgLength = tTypes.length + tOpTypes.length;
7877 int sArgLength = sTypes.length + sOpTypes.length; 7877 int sArgLength = sTypes.length + sOpTypes.length;
7878 // Check that the total number of parameters in t is greater than or equal to the number of 7878 // Check that the total number of parameters in t is greater than or equal to the number of
7879 // parameters in s and that the number of required parameters in s is grea ter than or equal to 7879 // parameters in s and that the number of required parameters in s is grea ter than or equal to
7880 // the number of required parameters in t. 7880 // the number of required parameters in t.
7881 if (tArgLength < sArgLength || sTypes.length < tTypes.length) { 7881 if (tArgLength < sArgLength || sTypes.length < tTypes.length) {
7882 return false; 7882 return false;
7883 } 7883 }
7884 if (tOpTypes.length == 0 && sOpTypes.length == 0) { 7884 if (tOpTypes.length == 0 && sOpTypes.length == 0) {
7885 // No positional arguments, don't copy contents to new array 7885 // No positional arguments, don't copy contents to new array
7886 for (int i = 0; i < sTypes.length; i++) { 7886 for (int i = 0; i < sTypes.length; i++) {
7887 if (!(tTypes[i] as TypeImpl).isMoreSpecificThan3(sTypes[i], withDynami c, visitedTypePairs)) { 7887 if (!(tTypes[i] as TypeImpl).isMoreSpecificThan2(sTypes[i], withDynami c, visitedTypePairs)) {
7888 return false; 7888 return false;
7889 } 7889 }
7890 } 7890 }
7891 } else { 7891 } else {
7892 // Else, we do have positional parameters, copy required and positional parameter types into 7892 // Else, we do have positional parameters, copy required and positional parameter types into
7893 // arrays to do the compare (for loop below). 7893 // arrays to do the compare (for loop below).
7894 List<Type2> tAllTypes = new List<Type2>(sArgLength); 7894 List<Type2> tAllTypes = new List<Type2>(sArgLength);
7895 for (int i = 0; i < tTypes.length; i++) { 7895 for (int i = 0; i < tTypes.length; i++) {
7896 tAllTypes[i] = tTypes[i]; 7896 tAllTypes[i] = tTypes[i];
7897 } 7897 }
7898 for (int i = tTypes.length, j = 0; i < sArgLength; i++, j++) { 7898 for (int i = tTypes.length, j = 0; i < sArgLength; i++, j++) {
7899 tAllTypes[i] = tOpTypes[j]; 7899 tAllTypes[i] = tOpTypes[j];
7900 } 7900 }
7901 List<Type2> sAllTypes = new List<Type2>(sArgLength); 7901 List<Type2> sAllTypes = new List<Type2>(sArgLength);
7902 for (int i = 0; i < sTypes.length; i++) { 7902 for (int i = 0; i < sTypes.length; i++) {
7903 sAllTypes[i] = sTypes[i]; 7903 sAllTypes[i] = sTypes[i];
7904 } 7904 }
7905 for (int i = sTypes.length, j = 0; i < sArgLength; i++, j++) { 7905 for (int i = sTypes.length, j = 0; i < sArgLength; i++, j++) {
7906 sAllTypes[i] = sOpTypes[j]; 7906 sAllTypes[i] = sOpTypes[j];
7907 } 7907 }
7908 for (int i = 0; i < sAllTypes.length; i++) { 7908 for (int i = 0; i < sAllTypes.length; i++) {
7909 if (!(tAllTypes[i] as TypeImpl).isMoreSpecificThan3(sAllTypes[i], with Dynamic, visitedTypePairs)) { 7909 if (!(tAllTypes[i] as TypeImpl).isMoreSpecificThan2(sAllTypes[i], with Dynamic, visitedTypePairs)) {
7910 return false; 7910 return false;
7911 } 7911 }
7912 } 7912 }
7913 } 7913 }
7914 } 7914 }
7915 Type2 tRetType = t.returnType; 7915 Type2 tRetType = t.returnType;
7916 Type2 sRetType = s.returnType; 7916 Type2 sRetType = s.returnType;
7917 return sRetType.isVoid || (tRetType as TypeImpl).isMoreSpecificThan3(sRetTyp e, withDynamic, visitedTypePairs); 7917 return sRetType.isVoid || (tRetType as TypeImpl).isMoreSpecificThan2(sRetTyp e, withDynamic, visitedTypePairs);
7918 } 7918 }
7919 7919
7920 bool isAssignableTo(Type2 type) => isSubtypeOf3(type, new Set<TypeImpl_TypePai r>()); 7920 bool isAssignableTo(Type2 type) => isSubtypeOf2(type, new Set<TypeImpl_TypePai r>());
7921 7921
7922 FunctionTypeImpl substitute3(List<Type2> argumentTypes) => substitute2(argumen tTypes, typeArguments); 7922 FunctionTypeImpl substitute3(List<Type2> argumentTypes) => substitute2(argumen tTypes, typeArguments);
7923 7923
7924 FunctionTypeImpl substitute2(List<Type2> argumentTypes, List<Type2> parameterT ypes) { 7924 FunctionTypeImpl substitute2(List<Type2> argumentTypes, List<Type2> parameterT ypes) {
7925 if (argumentTypes.length != parameterTypes.length) { 7925 if (argumentTypes.length != parameterTypes.length) {
7926 throw new IllegalArgumentException("argumentTypes.length (${argumentTypes. length}) != parameterTypes.length (${parameterTypes.length})"); 7926 throw new IllegalArgumentException("argumentTypes.length (${argumentTypes. length}) != parameterTypes.length (${parameterTypes.length})");
7927 } 7927 }
7928 if (argumentTypes.length == 0) { 7928 if (argumentTypes.length == 0) {
7929 return this; 7929 return this;
7930 } 7930 }
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
8012 if (object is! FunctionTypeImpl) { 8012 if (object is! FunctionTypeImpl) {
8013 return false; 8013 return false;
8014 } 8014 }
8015 FunctionTypeImpl otherType = object as FunctionTypeImpl; 8015 FunctionTypeImpl otherType = object as FunctionTypeImpl;
8016 // If the visitedTypePairs already has the pair (this, type), use the elemen ts to determine equality 8016 // If the visitedTypePairs already has the pair (this, type), use the elemen ts to determine equality
8017 ElementPair elementPair = new ElementPair(element, otherType.element); 8017 ElementPair elementPair = new ElementPair(element, otherType.element);
8018 if (!visitedElementPairs.add(elementPair)) { 8018 if (!visitedElementPairs.add(elementPair)) {
8019 return elementPair.firstElt == elementPair.secondElt; 8019 return elementPair.firstElt == elementPair.secondElt;
8020 } 8020 }
8021 // Compute the result 8021 // Compute the result
8022 bool result = TypeImpl.equalArrays(normalParameterTypes, otherType.normalPar ameterTypes, visitedElementPairs) && TypeImpl.equalArrays(optionalParameterTypes , otherType.optionalParameterTypes, visitedElementPairs) && equals2(namedParamet erTypes, otherType.namedParameterTypes, visitedElementPairs) && (returnType as T ypeImpl).internalEquals(otherType.returnType, visitedElementPairs); 8022 bool result = TypeImpl.equalArrays(normalParameterTypes, otherType.normalPar ameterTypes, visitedElementPairs) && TypeImpl.equalArrays(optionalParameterTypes , otherType.optionalParameterTypes, visitedElementPairs) && _equals(namedParamet erTypes, otherType.namedParameterTypes, visitedElementPairs) && (returnType as T ypeImpl).internalEquals(otherType.returnType, visitedElementPairs);
8023 // Remove the pair from our visited pairs list 8023 // Remove the pair from our visited pairs list
8024 visitedElementPairs.remove(elementPair); 8024 visitedElementPairs.remove(elementPair);
8025 // Return the result 8025 // Return the result
8026 return result; 8026 return result;
8027 } 8027 }
8028 8028
8029 bool internalIsSubtypeOf(Type2 type, Set<TypeImpl_TypePair> visitedTypePairs) { 8029 bool internalIsSubtypeOf(Type2 type, Set<TypeImpl_TypePair> visitedTypePairs) {
8030 // trivial base cases 8030 // trivial base cases
8031 if (type == null) { 8031 if (type == null) {
8032 return false; 8032 return false;
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
8154 static List<InterfaceType> EMPTY_ARRAY = new List<InterfaceType>(0); 8154 static List<InterfaceType> EMPTY_ARRAY = new List<InterfaceType>(0);
8155 8155
8156 /** 8156 /**
8157 * This method computes the longest inheritance path from some passed [Type] t o Object. 8157 * This method computes the longest inheritance path from some passed [Type] t o Object.
8158 * 8158 *
8159 * @param type the [Type] to compute the longest inheritance path of from the passed 8159 * @param type the [Type] to compute the longest inheritance path of from the passed
8160 * [Type] to Object 8160 * [Type] to Object
8161 * @return the computed longest inheritance path to Object 8161 * @return the computed longest inheritance path to Object
8162 * @see InterfaceType#getLeastUpperBound(Type) 8162 * @see InterfaceType#getLeastUpperBound(Type)
8163 */ 8163 */
8164 static int computeLongestInheritancePathToObject(InterfaceType type) => comput eLongestInheritancePathToObject2(type, 0, new Set<ClassElement>()); 8164 static int computeLongestInheritancePathToObject(InterfaceType type) => _compu teLongestInheritancePathToObject(type, 0, new Set<ClassElement>());
8165 8165
8166 /** 8166 /**
8167 * Returns the set of all superinterfaces of the passed [Type]. 8167 * Returns the set of all superinterfaces of the passed [Type].
8168 * 8168 *
8169 * @param type the [Type] to compute the set of superinterfaces of 8169 * @param type the [Type] to compute the set of superinterfaces of
8170 * @return the [Set] of superinterfaces of the passed [Type] 8170 * @return the [Set] of superinterfaces of the passed [Type]
8171 * @see #getLeastUpperBound(Type) 8171 * @see #getLeastUpperBound(Type)
8172 */ 8172 */
8173 static Set<InterfaceType> computeSuperinterfaceSet(InterfaceType type) => comp uteSuperinterfaceSet2(type, new Set<InterfaceType>()); 8173 static Set<InterfaceType> computeSuperinterfaceSet(InterfaceType type) => _com puteSuperinterfaceSet(type, new Set<InterfaceType>());
8174 8174
8175 /** 8175 /**
8176 * This method computes the longest inheritance path from some passed [Type] t o Object. This 8176 * This method computes the longest inheritance path from some passed [Type] t o Object. This
8177 * method calls itself recursively, callers should use the public method 8177 * method calls itself recursively, callers should use the public method
8178 * [computeLongestInheritancePathToObject]. 8178 * [computeLongestInheritancePathToObject].
8179 * 8179 *
8180 * @param type the [Type] to compute the longest inheritance path of from the passed 8180 * @param type the [Type] to compute the longest inheritance path of from the passed
8181 * [Type] to Object 8181 * [Type] to Object
8182 * @param depth a field used recursively 8182 * @param depth a field used recursively
8183 * @param visitedClasses the classes that have already been visited 8183 * @param visitedClasses the classes that have already been visited
8184 * @return the computed longest inheritance path to Object 8184 * @return the computed longest inheritance path to Object
8185 * @see #computeLongestInheritancePathToObject(Type) 8185 * @see #computeLongestInheritancePathToObject(Type)
8186 * @see #getLeastUpperBound(Type) 8186 * @see #getLeastUpperBound(Type)
8187 */ 8187 */
8188 static int computeLongestInheritancePathToObject2(InterfaceType type, int dept h, Set<ClassElement> visitedClasses) { 8188 static int _computeLongestInheritancePathToObject(InterfaceType type, int dept h, Set<ClassElement> visitedClasses) {
8189 ClassElement classElement = type.element; 8189 ClassElement classElement = type.element;
8190 // Object case 8190 // Object case
8191 if (classElement.supertype == null || visitedClasses.contains(classElement)) { 8191 if (classElement.supertype == null || visitedClasses.contains(classElement)) {
8192 return depth; 8192 return depth;
8193 } 8193 }
8194 int longestPath = 1; 8194 int longestPath = 1;
8195 try { 8195 try {
8196 visitedClasses.add(classElement); 8196 visitedClasses.add(classElement);
8197 List<InterfaceType> superinterfaces = classElement.interfaces; 8197 List<InterfaceType> superinterfaces = classElement.interfaces;
8198 int pathLength; 8198 int pathLength;
8199 if (superinterfaces.length > 0) { 8199 if (superinterfaces.length > 0) {
8200 // loop through each of the superinterfaces recursively calling this met hod and keeping track 8200 // loop through each of the superinterfaces recursively calling this met hod and keeping track
8201 // of the longest path to return 8201 // of the longest path to return
8202 for (InterfaceType superinterface in superinterfaces) { 8202 for (InterfaceType superinterface in superinterfaces) {
8203 pathLength = computeLongestInheritancePathToObject2(superinterface, de pth + 1, visitedClasses); 8203 pathLength = _computeLongestInheritancePathToObject(superinterface, de pth + 1, visitedClasses);
8204 if (pathLength > longestPath) { 8204 if (pathLength > longestPath) {
8205 longestPath = pathLength; 8205 longestPath = pathLength;
8206 } 8206 }
8207 } 8207 }
8208 } 8208 }
8209 // finally, perform this same check on the super type 8209 // finally, perform this same check on the super type
8210 // TODO(brianwilkerson) Does this also need to add in the number of mixin classes? 8210 // TODO(brianwilkerson) Does this also need to add in the number of mixin classes?
8211 InterfaceType supertype = classElement.supertype; 8211 InterfaceType supertype = classElement.supertype;
8212 pathLength = computeLongestInheritancePathToObject2(supertype, depth + 1, visitedClasses); 8212 pathLength = _computeLongestInheritancePathToObject(supertype, depth + 1, visitedClasses);
8213 if (pathLength > longestPath) { 8213 if (pathLength > longestPath) {
8214 longestPath = pathLength; 8214 longestPath = pathLength;
8215 } 8215 }
8216 } finally { 8216 } finally {
8217 visitedClasses.remove(classElement); 8217 visitedClasses.remove(classElement);
8218 } 8218 }
8219 return longestPath; 8219 return longestPath;
8220 } 8220 }
8221 8221
8222 /** 8222 /**
8223 * Returns the set of all superinterfaces of the passed [Type]. This is a recu rsive method, 8223 * Returns the set of all superinterfaces of the passed [Type]. This is a recu rsive method,
8224 * callers should call the public [computeSuperinterfaceSet]. 8224 * callers should call the public [computeSuperinterfaceSet].
8225 * 8225 *
8226 * @param type the [Type] to compute the set of superinterfaces of 8226 * @param type the [Type] to compute the set of superinterfaces of
8227 * @param set a [HashSet] used recursively by this method 8227 * @param set a [HashSet] used recursively by this method
8228 * @return the [Set] of superinterfaces of the passed [Type] 8228 * @return the [Set] of superinterfaces of the passed [Type]
8229 * @see #computeSuperinterfaceSet(Type) 8229 * @see #computeSuperinterfaceSet(Type)
8230 * @see #getLeastUpperBound(Type) 8230 * @see #getLeastUpperBound(Type)
8231 */ 8231 */
8232 static Set<InterfaceType> computeSuperinterfaceSet2(InterfaceType type, Set<In terfaceType> set) { 8232 static Set<InterfaceType> _computeSuperinterfaceSet(InterfaceType type, Set<In terfaceType> set) {
8233 Element element = type.element; 8233 Element element = type.element;
8234 if (element != null && element is ClassElement) { 8234 if (element != null && element is ClassElement) {
8235 ClassElement classElement = element; 8235 ClassElement classElement = element;
8236 List<InterfaceType> superinterfaces = classElement.interfaces; 8236 List<InterfaceType> superinterfaces = classElement.interfaces;
8237 for (InterfaceType superinterface in superinterfaces) { 8237 for (InterfaceType superinterface in superinterfaces) {
8238 if (set.add(superinterface)) { 8238 if (set.add(superinterface)) {
8239 computeSuperinterfaceSet2(superinterface, set); 8239 _computeSuperinterfaceSet(superinterface, set);
8240 } 8240 }
8241 } 8241 }
8242 InterfaceType supertype = classElement.supertype; 8242 InterfaceType supertype = classElement.supertype;
8243 if (supertype != null) { 8243 if (supertype != null) {
8244 if (set.add(supertype)) { 8244 if (set.add(supertype)) {
8245 computeSuperinterfaceSet2(supertype, set); 8245 _computeSuperinterfaceSet(supertype, set);
8246 } 8246 }
8247 } 8247 }
8248 } 8248 }
8249 return set; 8249 return set;
8250 } 8250 }
8251 8251
8252 /** 8252 /**
8253 * Return the intersection of the given sets of types, where intersection is b ased on the equality 8253 * Return the intersection of the given sets of types, where intersection is b ased on the equality
8254 * of the elements of the types rather than on the equality of the types thems elves. In cases 8254 * of the elements of the types rather than on the equality of the types thems elves. In cases
8255 * where two non-equal types have equal elements, which only happens when the class is 8255 * where two non-equal types have equal elements, which only happens when the class is
8256 * parameterized, the type that is added to the intersection is the base type with type arguments 8256 * parameterized, the type that is added to the intersection is the base type with type arguments
8257 * that are the least upper bound of the type arguments of the two types. 8257 * that are the least upper bound of the type arguments of the two types.
8258 * 8258 *
8259 * @param first the first set of types to be intersected 8259 * @param first the first set of types to be intersected
8260 * @param second the second set of types to be intersected 8260 * @param second the second set of types to be intersected
8261 * @return the intersection of the given sets of types 8261 * @return the intersection of the given sets of types
8262 */ 8262 */
8263 static List<InterfaceType> intersection(Set<InterfaceType> first, Set<Interfac eType> second) { 8263 static List<InterfaceType> _intersection(Set<InterfaceType> first, Set<Interfa ceType> second) {
8264 Map<ClassElement, InterfaceType> firstMap = new Map<ClassElement, InterfaceT ype>(); 8264 Map<ClassElement, InterfaceType> firstMap = new Map<ClassElement, InterfaceT ype>();
8265 for (InterfaceType firstType in first) { 8265 for (InterfaceType firstType in first) {
8266 firstMap[firstType.element] = firstType; 8266 firstMap[firstType.element] = firstType;
8267 } 8267 }
8268 Set<InterfaceType> result = new Set<InterfaceType>(); 8268 Set<InterfaceType> result = new Set<InterfaceType>();
8269 for (InterfaceType secondType in second) { 8269 for (InterfaceType secondType in second) {
8270 InterfaceType firstType = firstMap[secondType.element]; 8270 InterfaceType firstType = firstMap[secondType.element];
8271 if (firstType != null) { 8271 if (firstType != null) {
8272 result.add(leastUpperBound(firstType, secondType)); 8272 result.add(_leastUpperBound(firstType, secondType));
8273 } 8273 }
8274 } 8274 }
8275 return new List.from(result); 8275 return new List.from(result);
8276 } 8276 }
8277 8277
8278 /** 8278 /**
8279 * Return the "least upper bound" of the given types under the assumption that the types have the 8279 * Return the "least upper bound" of the given types under the assumption that the types have the
8280 * same element and differ only in terms of the type arguments. The resulting type is composed by 8280 * same element and differ only in terms of the type arguments. The resulting type is composed by
8281 * comparing the corresponding type arguments, keeping those that are the same , and using 8281 * comparing the corresponding type arguments, keeping those that are the same , and using
8282 * 'dynamic' for those that are different. 8282 * 'dynamic' for those that are different.
8283 * 8283 *
8284 * @param firstType the first type 8284 * @param firstType the first type
8285 * @param secondType the second type 8285 * @param secondType the second type
8286 * @return the "least upper bound" of the given types 8286 * @return the "least upper bound" of the given types
8287 */ 8287 */
8288 static InterfaceType leastUpperBound(InterfaceType firstType, InterfaceType se condType) { 8288 static InterfaceType _leastUpperBound(InterfaceType firstType, InterfaceType s econdType) {
8289 if (firstType == secondType) { 8289 if (firstType == secondType) {
8290 return firstType; 8290 return firstType;
8291 } 8291 }
8292 List<Type2> firstArguments = firstType.typeArguments; 8292 List<Type2> firstArguments = firstType.typeArguments;
8293 List<Type2> secondArguments = secondType.typeArguments; 8293 List<Type2> secondArguments = secondType.typeArguments;
8294 int argumentCount = firstArguments.length; 8294 int argumentCount = firstArguments.length;
8295 if (argumentCount == 0) { 8295 if (argumentCount == 0) {
8296 return firstType; 8296 return firstType;
8297 } 8297 }
8298 List<Type2> lubArguments = new List<Type2>(argumentCount); 8298 List<Type2> lubArguments = new List<Type2>(argumentCount);
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
8409 // new names to match up with the spec 8409 // new names to match up with the spec
8410 InterfaceType i = this; 8410 InterfaceType i = this;
8411 InterfaceType j = type as InterfaceType; 8411 InterfaceType j = type as InterfaceType;
8412 // compute set of supertypes 8412 // compute set of supertypes
8413 Set<InterfaceType> si = computeSuperinterfaceSet(i); 8413 Set<InterfaceType> si = computeSuperinterfaceSet(i);
8414 Set<InterfaceType> sj = computeSuperinterfaceSet(j); 8414 Set<InterfaceType> sj = computeSuperinterfaceSet(j);
8415 // union si with i and sj with j 8415 // union si with i and sj with j
8416 si.add(i); 8416 si.add(i);
8417 sj.add(j); 8417 sj.add(j);
8418 // compute intersection, reference as set 's' 8418 // compute intersection, reference as set 's'
8419 List<InterfaceType> s = intersection(si, sj); 8419 List<InterfaceType> s = _intersection(si, sj);
8420 // for each element in Set s, compute the largest inheritance path to Object 8420 // for each element in Set s, compute the largest inheritance path to Object
8421 List<int> depths = new List<int>.filled(s.length, 0); 8421 List<int> depths = new List<int>.filled(s.length, 0);
8422 int maxDepth = 0; 8422 int maxDepth = 0;
8423 for (int n = 0; n < s.length; n++) { 8423 for (int n = 0; n < s.length; n++) {
8424 depths[n] = computeLongestInheritancePathToObject(s[n]); 8424 depths[n] = computeLongestInheritancePathToObject(s[n]);
8425 if (depths[n] > maxDepth) { 8425 if (depths[n] > maxDepth) {
8426 maxDepth = depths[n]; 8426 maxDepth = depths[n];
8427 } 8427 }
8428 } 8428 }
8429 // ensure that the currently computed maxDepth is unique, 8429 // ensure that the currently computed maxDepth is unique,
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
8720 // 8720 //
8721 // S is dynamic. 8721 // S is dynamic.
8722 // The test to determine whether S is dynamic is done here because dynamic i s not an instance of 8722 // The test to determine whether S is dynamic is done here because dynamic i s not an instance of
8723 // InterfaceType. 8723 // InterfaceType.
8724 // 8724 //
8725 if (identical(type, DynamicTypeImpl.instance)) { 8725 if (identical(type, DynamicTypeImpl.instance)) {
8726 return true; 8726 return true;
8727 } else if (type is! InterfaceType) { 8727 } else if (type is! InterfaceType) {
8728 return false; 8728 return false;
8729 } 8729 }
8730 return isMoreSpecificThan2(type as InterfaceType, new Set<ClassElement>(), w ithDynamic, visitedTypePairs); 8730 return _isMoreSpecificThan(type as InterfaceType, new Set<ClassElement>(), w ithDynamic, visitedTypePairs);
8731 } 8731 }
8732 8732
8733 bool internalIsSubtypeOf(Type2 type, Set<TypeImpl_TypePair> visitedTypePairs) { 8733 bool internalIsSubtypeOf(Type2 type, Set<TypeImpl_TypePair> visitedTypePairs) {
8734 // 8734 //
8735 // T is a subtype of S, written T <: S, iff [bottom/dynamic]T << S 8735 // T is a subtype of S, written T <: S, iff [bottom/dynamic]T << S
8736 // 8736 //
8737 if (identical(type, DynamicTypeImpl.instance)) { 8737 if (identical(type, DynamicTypeImpl.instance)) {
8738 return true; 8738 return true;
8739 } else if (type is TypeParameterType) { 8739 } else if (type is TypeParameterType) {
8740 return true; 8740 return true;
8741 } else if (type is FunctionType) { 8741 } else if (type is FunctionType) {
8742 ClassElement element = this.element; 8742 ClassElement element = this.element;
8743 MethodElement callMethod = element.lookUpMethod("call", element.library); 8743 MethodElement callMethod = element.lookUpMethod("call", element.library);
8744 if (callMethod != null) { 8744 if (callMethod != null) {
8745 return callMethod.type.isSubtypeOf(type); 8745 return callMethod.type.isSubtypeOf(type);
8746 } 8746 }
8747 return false; 8747 return false;
8748 } else if (type is! InterfaceType) { 8748 } else if (type is! InterfaceType) {
8749 return false; 8749 return false;
8750 } else if (this == type) { 8750 } else if (this == type) {
8751 return true; 8751 return true;
8752 } 8752 }
8753 return isSubtypeOf2(type as InterfaceType, new Set<ClassElement>(), visitedT ypePairs); 8753 return _isSubtypeOf(type as InterfaceType, new Set<ClassElement>(), visitedT ypePairs);
8754 } 8754 }
8755 8755
8756 bool isMoreSpecificThan2(InterfaceType s, Set<ClassElement> visitedClasses, bo ol withDynamic, Set<TypeImpl_TypePair> visitedTypePairs) { 8756 bool _isMoreSpecificThan(InterfaceType s, Set<ClassElement> visitedClasses, bo ol withDynamic, Set<TypeImpl_TypePair> visitedTypePairs) {
8757 // 8757 //
8758 // A type T is more specific than a type S, written T << S, if one of the f ollowing conditions 8758 // A type T is more specific than a type S, written T << S, if one of the f ollowing conditions
8759 // is met: 8759 // is met:
8760 // 8760 //
8761 // Reflexivity: T is S. 8761 // Reflexivity: T is S.
8762 // 8762 //
8763 if (this == s) { 8763 if (this == s) {
8764 return true; 8764 return true;
8765 } 8765 }
8766 // 8766 //
8767 // T is bottom. (This case is handled by the class BottomTypeImpl.) 8767 // T is bottom. (This case is handled by the class BottomTypeImpl.)
8768 // 8768 //
8769 // Direct supertype: S is a direct supertype of T. 8769 // Direct supertype: S is a direct supertype of T.
8770 // 8770 //
8771 if (s.isDirectSupertypeOf(this)) { 8771 if (s.isDirectSupertypeOf(this)) {
8772 return true; 8772 return true;
8773 } 8773 }
8774 // 8774 //
8775 // Covariance: T is of the form I<T1, ..., Tn> and S is of the form I<S1, .. ., Sn> and Ti << Si, 1 <= i <= n. 8775 // Covariance: T is of the form I<T1, ..., Tn> and S is of the form I<S1, .. ., Sn> and Ti << Si, 1 <= i <= n.
8776 // 8776 //
8777 ClassElement tElement = this.element; 8777 ClassElement tElement = this.element;
8778 ClassElement sElement = s.element; 8778 ClassElement sElement = s.element;
8779 if (tElement == sElement) { 8779 if (tElement == sElement) {
8780 List<Type2> tArguments = typeArguments; 8780 List<Type2> tArguments = typeArguments;
8781 List<Type2> sArguments = s.typeArguments; 8781 List<Type2> sArguments = s.typeArguments;
8782 if (tArguments.length != sArguments.length) { 8782 if (tArguments.length != sArguments.length) {
8783 return false; 8783 return false;
8784 } 8784 }
8785 for (int i = 0; i < tArguments.length; i++) { 8785 for (int i = 0; i < tArguments.length; i++) {
8786 if (!(tArguments[i] as TypeImpl).isMoreSpecificThan3(sArguments[i], with Dynamic, visitedTypePairs)) { 8786 if (!(tArguments[i] as TypeImpl).isMoreSpecificThan2(sArguments[i], with Dynamic, visitedTypePairs)) {
8787 return false; 8787 return false;
8788 } 8788 }
8789 } 8789 }
8790 return true; 8790 return true;
8791 } 8791 }
8792 // 8792 //
8793 // Transitivity: T << U and U << S. 8793 // Transitivity: T << U and U << S.
8794 // 8794 //
8795 // First check for infinite loops 8795 // First check for infinite loops
8796 ClassElement element = this.element; 8796 ClassElement element = this.element;
8797 if (element == null || visitedClasses.contains(element)) { 8797 if (element == null || visitedClasses.contains(element)) {
8798 return false; 8798 return false;
8799 } 8799 }
8800 visitedClasses.add(element); 8800 visitedClasses.add(element);
8801 // Iterate over all of the types U that are more specific than T because the y are direct 8801 // Iterate over all of the types U that are more specific than T because the y are direct
8802 // supertypes of T and return true if any of them are more specific than S. 8802 // supertypes of T and return true if any of them are more specific than S.
8803 InterfaceType supertype = superclass; 8803 InterfaceType supertype = superclass;
8804 if (supertype != null && (supertype as InterfaceTypeImpl).isMoreSpecificThan 2(s, visitedClasses, withDynamic, visitedTypePairs)) { 8804 if (supertype != null && (supertype as InterfaceTypeImpl)._isMoreSpecificTha n(s, visitedClasses, withDynamic, visitedTypePairs)) {
8805 return true; 8805 return true;
8806 } 8806 }
8807 for (InterfaceType interfaceType in interfaces) { 8807 for (InterfaceType interfaceType in interfaces) {
8808 if ((interfaceType as InterfaceTypeImpl).isMoreSpecificThan2(s, visitedCla sses, withDynamic, visitedTypePairs)) { 8808 if ((interfaceType as InterfaceTypeImpl)._isMoreSpecificThan(s, visitedCla sses, withDynamic, visitedTypePairs)) {
8809 return true; 8809 return true;
8810 } 8810 }
8811 } 8811 }
8812 for (InterfaceType mixinType in mixins) { 8812 for (InterfaceType mixinType in mixins) {
8813 if ((mixinType as InterfaceTypeImpl).isMoreSpecificThan2(s, visitedClasses , withDynamic, visitedTypePairs)) { 8813 if ((mixinType as InterfaceTypeImpl)._isMoreSpecificThan(s, visitedClasses , withDynamic, visitedTypePairs)) {
8814 return true; 8814 return true;
8815 } 8815 }
8816 } 8816 }
8817 return false; 8817 return false;
8818 } 8818 }
8819 8819
8820 bool isSubtypeOf2(InterfaceType type, Set<ClassElement> visitedClasses, Set<Ty peImpl_TypePair> visitedTypePairs) { 8820 bool _isSubtypeOf(InterfaceType type, Set<ClassElement> visitedClasses, Set<Ty peImpl_TypePair> visitedTypePairs) {
8821 InterfaceType typeT = this; 8821 InterfaceType typeT = this;
8822 InterfaceType typeS = type; 8822 InterfaceType typeS = type;
8823 ClassElement elementT = element; 8823 ClassElement elementT = element;
8824 if (elementT == null || visitedClasses.contains(elementT)) { 8824 if (elementT == null || visitedClasses.contains(elementT)) {
8825 return false; 8825 return false;
8826 } 8826 }
8827 visitedClasses.add(elementT); 8827 visitedClasses.add(elementT);
8828 if (typeT == typeS) { 8828 if (typeT == typeS) {
8829 return true; 8829 return true;
8830 } else if (elementT == typeS.element) { 8830 } else if (elementT == typeS.element) {
8831 // For each of the type arguments return true if all type args from T is a subtype of all 8831 // For each of the type arguments return true if all type args from T is a subtype of all
8832 // types from S. 8832 // types from S.
8833 List<Type2> typeTArgs = typeT.typeArguments; 8833 List<Type2> typeTArgs = typeT.typeArguments;
8834 List<Type2> typeSArgs = typeS.typeArguments; 8834 List<Type2> typeSArgs = typeS.typeArguments;
8835 if (typeTArgs.length != typeSArgs.length) { 8835 if (typeTArgs.length != typeSArgs.length) {
8836 // This case covers the case where two objects are being compared that h ave a different 8836 // This case covers the case where two objects are being compared that h ave a different
8837 // number of parameterized types. 8837 // number of parameterized types.
8838 return false; 8838 return false;
8839 } 8839 }
8840 for (int i = 0; i < typeTArgs.length; i++) { 8840 for (int i = 0; i < typeTArgs.length; i++) {
8841 // Recursively call isSubtypeOf the type arguments and return false if t he T argument is not 8841 // Recursively call isSubtypeOf the type arguments and return false if t he T argument is not
8842 // a subtype of the S argument. 8842 // a subtype of the S argument.
8843 if (!(typeTArgs[i] as TypeImpl).isSubtypeOf3(typeSArgs[i], visitedTypePa irs)) { 8843 if (!(typeTArgs[i] as TypeImpl).isSubtypeOf2(typeSArgs[i], visitedTypePa irs)) {
8844 return false; 8844 return false;
8845 } 8845 }
8846 } 8846 }
8847 return true; 8847 return true;
8848 } else if (typeS.isDartCoreFunction && elementT.getMethod("call") != null) { 8848 } else if (typeS.isDartCoreFunction && elementT.getMethod("call") != null) {
8849 return true; 8849 return true;
8850 } 8850 }
8851 InterfaceType supertype = superclass; 8851 InterfaceType supertype = superclass;
8852 // The type is Object, return false. 8852 // The type is Object, return false.
8853 if (supertype != null && (supertype as InterfaceTypeImpl).isSubtypeOf2(typeS , visitedClasses, visitedTypePairs)) { 8853 if (supertype != null && (supertype as InterfaceTypeImpl)._isSubtypeOf(typeS , visitedClasses, visitedTypePairs)) {
8854 return true; 8854 return true;
8855 } 8855 }
8856 List<InterfaceType> interfaceTypes = interfaces; 8856 List<InterfaceType> interfaceTypes = interfaces;
8857 for (InterfaceType interfaceType in interfaceTypes) { 8857 for (InterfaceType interfaceType in interfaceTypes) {
8858 if ((interfaceType as InterfaceTypeImpl).isSubtypeOf2(typeS, visitedClasse s, visitedTypePairs)) { 8858 if ((interfaceType as InterfaceTypeImpl)._isSubtypeOf(typeS, visitedClasse s, visitedTypePairs)) {
8859 return true; 8859 return true;
8860 } 8860 }
8861 } 8861 }
8862 List<InterfaceType> mixinTypes = mixins; 8862 List<InterfaceType> mixinTypes = mixins;
8863 for (InterfaceType mixinType in mixinTypes) { 8863 for (InterfaceType mixinType in mixinTypes) {
8864 if ((mixinType as InterfaceTypeImpl).isSubtypeOf2(typeS, visitedClasses, v isitedTypePairs)) { 8864 if ((mixinType as InterfaceTypeImpl)._isSubtypeOf(typeS, visitedClasses, v isitedTypePairs)) {
8865 return true; 8865 return true;
8866 } 8866 }
8867 } 8867 }
8868 return false; 8868 return false;
8869 } 8869 }
8870 } 8870 }
8871 8871
8872 /** 8872 /**
8873 * The abstract class `TypeImpl` implements the behavior common to objects repre senting the 8873 * The abstract class `TypeImpl` implements the behavior common to objects repre senting the
8874 * declared type of elements in the element model. 8874 * declared type of elements in the element model.
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
8947 * or <i>S</i> <: <i>T</i>. 8947 * or <i>S</i> <: <i>T</i>.
8948 * 8948 *
8949 * The given set of pairs of types (T1, T2), where each pair indicates that we invoked this method 8949 * The given set of pairs of types (T1, T2), where each pair indicates that we invoked this method
8950 * because we are in the process of answering the question of whether T1 is a subtype of T2, is 8950 * because we are in the process of answering the question of whether T1 is a subtype of T2, is
8951 * used to prevent infinite loops. 8951 * used to prevent infinite loops.
8952 * 8952 *
8953 * @param type the type being compared with this type 8953 * @param type the type being compared with this type
8954 * @param visitedPairs the set of pairs of types used to prevent infinite loop s 8954 * @param visitedPairs the set of pairs of types used to prevent infinite loop s
8955 * @return `true` if this type is assignable to the given type 8955 * @return `true` if this type is assignable to the given type
8956 */ 8956 */
8957 bool isAssignableTo2(Type2 type, Set<TypeImpl_TypePair> visitedTypePairs) => i sSubtypeOf3(type, visitedTypePairs) || (type as TypeImpl).isSubtypeOf3(this, vis itedTypePairs); 8957 bool isAssignableTo2(Type2 type, Set<TypeImpl_TypePair> visitedTypePairs) => i sSubtypeOf2(type, visitedTypePairs) || (type as TypeImpl).isSubtypeOf2(this, vis itedTypePairs);
8958 8958
8959 bool get isBottom => false; 8959 bool get isBottom => false;
8960 8960
8961 bool get isDartCoreFunction => false; 8961 bool get isDartCoreFunction => false;
8962 8962
8963 bool get isDynamic => false; 8963 bool get isDynamic => false;
8964 8964
8965 bool isMoreSpecificThan(Type2 type) => isMoreSpecificThan3(type, false, new Se t<TypeImpl_TypePair>()); 8965 bool isMoreSpecificThan(Type2 type) => isMoreSpecificThan2(type, false, new Se t<TypeImpl_TypePair>());
8966 8966
8967 /** 8967 /**
8968 * Return `true` if this type is more specific than the given type. 8968 * Return `true` if this type is more specific than the given type.
8969 * 8969 *
8970 * The given set of pairs of types (T1, T2), where each pair indicates that we invoked this method 8970 * The given set of pairs of types (T1, T2), where each pair indicates that we invoked this method
8971 * because we are in the process of answering the question of whether T1 is a subtype of T2, is 8971 * because we are in the process of answering the question of whether T1 is a subtype of T2, is
8972 * used to prevent infinite loops. 8972 * used to prevent infinite loops.
8973 * 8973 *
8974 * @param type the type being compared with this type 8974 * @param type the type being compared with this type
8975 * @param withDynamic `true` if "dynamic" should be considered as a subtype of any type 8975 * @param withDynamic `true` if "dynamic" should be considered as a subtype of any type
8976 * @param visitedPairs the set of pairs of types used to prevent infinite loop s 8976 * @param visitedPairs the set of pairs of types used to prevent infinite loop s
8977 * @return `true` if this type is more specific than the given type 8977 * @return `true` if this type is more specific than the given type
8978 */ 8978 */
8979 bool isMoreSpecificThan3(Type2 type, bool withDynamic, Set<TypeImpl_TypePair> visitedTypePairs) { 8979 bool isMoreSpecificThan2(Type2 type, bool withDynamic, Set<TypeImpl_TypePair> visitedTypePairs) {
8980 // If the visitedTypePairs already has the pair (this, type), return false 8980 // If the visitedTypePairs already has the pair (this, type), return false
8981 TypeImpl_TypePair typePair = new TypeImpl_TypePair(this, type); 8981 TypeImpl_TypePair typePair = new TypeImpl_TypePair(this, type);
8982 if (!visitedTypePairs.add(typePair)) { 8982 if (!visitedTypePairs.add(typePair)) {
8983 return false; 8983 return false;
8984 } 8984 }
8985 bool result = internalIsMoreSpecificThan(type, withDynamic, visitedTypePairs ); 8985 bool result = internalIsMoreSpecificThan(type, withDynamic, visitedTypePairs );
8986 visitedTypePairs.remove(typePair); 8986 visitedTypePairs.remove(typePair);
8987 return result; 8987 return result;
8988 } 8988 }
8989 8989
8990 bool get isObject => false; 8990 bool get isObject => false;
8991 8991
8992 bool isSubtypeOf(Type2 type) => isSubtypeOf3(type, new Set<TypeImpl_TypePair>( )); 8992 bool isSubtypeOf(Type2 type) => isSubtypeOf2(type, new Set<TypeImpl_TypePair>( ));
8993 8993
8994 /** 8994 /**
8995 * Return `true` if this type is a subtype of the given type. 8995 * Return `true` if this type is a subtype of the given type.
8996 * 8996 *
8997 * The given set of pairs of types (T1, T2), where each pair indicates that we invoked this method 8997 * The given set of pairs of types (T1, T2), where each pair indicates that we invoked this method
8998 * because we are in the process of answering the question of whether T1 is a subtype of T2, is 8998 * because we are in the process of answering the question of whether T1 is a subtype of T2, is
8999 * used to prevent infinite loops. 8999 * used to prevent infinite loops.
9000 * 9000 *
9001 * @param type the type being compared with this type 9001 * @param type the type being compared with this type
9002 * @param visitedPairs the set of pairs of types used to prevent infinite loop s 9002 * @param visitedPairs the set of pairs of types used to prevent infinite loop s
9003 * @return `true` if this type is a subtype of the given type 9003 * @return `true` if this type is a subtype of the given type
9004 */ 9004 */
9005 bool isSubtypeOf3(Type2 type, Set<TypeImpl_TypePair> visitedTypePairs) { 9005 bool isSubtypeOf2(Type2 type, Set<TypeImpl_TypePair> visitedTypePairs) {
9006 // If the visitedTypePairs already has the pair (this, type), return false 9006 // If the visitedTypePairs already has the pair (this, type), return false
9007 TypeImpl_TypePair typePair = new TypeImpl_TypePair(this, type); 9007 TypeImpl_TypePair typePair = new TypeImpl_TypePair(this, type);
9008 if (!visitedTypePairs.add(typePair)) { 9008 if (!visitedTypePairs.add(typePair)) {
9009 return false; 9009 return false;
9010 } 9010 }
9011 bool result = internalIsSubtypeOf(type, visitedTypePairs); 9011 bool result = internalIsSubtypeOf(type, visitedTypePairs);
9012 visitedTypePairs.remove(typePair); 9012 visitedTypePairs.remove(typePair);
9013 return result; 9013 return result;
9014 } 9014 }
9015 9015
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
9146 // S is bottom. 9146 // S is bottom.
9147 // 9147 //
9148 if (s.isBottom) { 9148 if (s.isBottom) {
9149 return true; 9149 return true;
9150 } 9150 }
9151 // S is dynamic. 9151 // S is dynamic.
9152 // 9152 //
9153 if (s.isDynamic) { 9153 if (s.isDynamic) {
9154 return true; 9154 return true;
9155 } 9155 }
9156 return isMoreSpecificThan4(s, new Set<Type2>(), withDynamic, visitedTypePair s); 9156 return _isMoreSpecificThan(s, new Set<Type2>(), withDynamic, visitedTypePair s);
9157 } 9157 }
9158 9158
9159 bool internalIsSubtypeOf(Type2 type, Set<TypeImpl_TypePair> visitedTypePairs) => isMoreSpecificThan3(type, true, new Set<TypeImpl_TypePair>()); 9159 bool internalIsSubtypeOf(Type2 type, Set<TypeImpl_TypePair> visitedTypePairs) => isMoreSpecificThan2(type, true, new Set<TypeImpl_TypePair>());
9160 9160
9161 bool isMoreSpecificThan4(Type2 s, Set<Type2> visitedTypes, bool withDynamic, S et<TypeImpl_TypePair> visitedTypePairs) { 9161 bool _isMoreSpecificThan(Type2 s, Set<Type2> visitedTypes, bool withDynamic, S et<TypeImpl_TypePair> visitedTypePairs) {
9162 // T is a type parameter and S is the upper bound of T. 9162 // T is a type parameter and S is the upper bound of T.
9163 // 9163 //
9164 Type2 bound = element.bound; 9164 Type2 bound = element.bound;
9165 if (s == bound) { 9165 if (s == bound) {
9166 return true; 9166 return true;
9167 } 9167 }
9168 // T is a type parameter and S is Object. 9168 // T is a type parameter and S is Object.
9169 // 9169 //
9170 if (s.isObject) { 9170 if (s.isObject) {
9171 return true; 9171 return true;
9172 } 9172 }
9173 // We need upper bound to continue. 9173 // We need upper bound to continue.
9174 if (bound == null) { 9174 if (bound == null) {
9175 return false; 9175 return false;
9176 } 9176 }
9177 // 9177 //
9178 // Transitivity: T << U and U << S. 9178 // Transitivity: T << U and U << S.
9179 // 9179 //
9180 if (bound is TypeParameterTypeImpl) { 9180 if (bound is TypeParameterTypeImpl) {
9181 TypeParameterTypeImpl boundTypeParameter = bound; 9181 TypeParameterTypeImpl boundTypeParameter = bound;
9182 // First check for infinite loops 9182 // First check for infinite loops
9183 if (visitedTypes.contains(bound)) { 9183 if (visitedTypes.contains(bound)) {
9184 return false; 9184 return false;
9185 } 9185 }
9186 visitedTypes.add(bound); 9186 visitedTypes.add(bound);
9187 // Then check upper bound. 9187 // Then check upper bound.
9188 return boundTypeParameter.isMoreSpecificThan4(s, visitedTypes, withDynamic , visitedTypePairs); 9188 return boundTypeParameter._isMoreSpecificThan(s, visitedTypes, withDynamic , visitedTypePairs);
9189 } 9189 }
9190 // Check interface type. 9190 // Check interface type.
9191 return (bound as TypeImpl).isMoreSpecificThan3(s, withDynamic, visitedTypePa irs); 9191 return (bound as TypeImpl).isMoreSpecificThan2(s, withDynamic, visitedTypePa irs);
9192 } 9192 }
9193 } 9193 }
9194 9194
9195 /** 9195 /**
9196 * The unique instance of the class `VoidTypeImpl` implements the type `void`. 9196 * The unique instance of the class `VoidTypeImpl` implements the type `void`.
9197 */ 9197 */
9198 class VoidTypeImpl extends TypeImpl implements VoidType { 9198 class VoidTypeImpl extends TypeImpl implements VoidType {
9199 /** 9199 /**
9200 * The unique instance of this class. 9200 * The unique instance of this class.
9201 */ 9201 */
(...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after
9797 TypeParameterElement get element; 9797 TypeParameterElement get element;
9798 } 9798 }
9799 9799
9800 /** 9800 /**
9801 * The interface `VoidType` defines the behavior of the unique object representi ng the type 9801 * The interface `VoidType` defines the behavior of the unique object representi ng the type
9802 * `void`. 9802 * `void`.
9803 */ 9803 */
9804 abstract class VoidType implements Type2 { 9804 abstract class VoidType implements Type2 {
9805 VoidType substitute2(List<Type2> argumentTypes, List<Type2> parameterTypes); 9805 VoidType substitute2(List<Type2> argumentTypes, List<Type2> parameterTypes);
9806 } 9806 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/constant.dart ('k') | pkg/analyzer/lib/src/generated/engine.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698