| 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 | 3 |
| 4 library engine.element; | 4 library engine.element; |
| 5 | 5 |
| 6 import 'dart:collection'; | 6 import 'dart:collection'; |
| 7 import 'java_core.dart'; | 7 import 'java_core.dart'; |
| 8 import 'java_engine.dart'; | 8 import 'java_engine.dart'; |
| 9 import 'utilities_collection.dart'; | 9 import 'utilities_collection.dart'; |
| 10 import 'source.dart'; | 10 import 'source.dart'; |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 /** | 175 /** |
| 176 * Return `true` if this class is abstract. A class is abstract if it has an e
xplicit | 176 * Return `true` if this class is abstract. A class is abstract if it has an e
xplicit |
| 177 * `abstract` modifier. Note, that this definition of <i>abstract</i> is diffe
rent from | 177 * `abstract` modifier. Note, that this definition of <i>abstract</i> is diffe
rent from |
| 178 * <i>has unimplemented members</i>. | 178 * <i>has unimplemented members</i>. |
| 179 * | 179 * |
| 180 * @return `true` if this class is abstract | 180 * @return `true` if this class is abstract |
| 181 */ | 181 */ |
| 182 bool get isAbstract; | 182 bool get isAbstract; |
| 183 | 183 |
| 184 /** | 184 /** |
| 185 * Return `true` if this element has an annotation of the form '@proxy'. |
| 186 * |
| 187 * @return `true` if this element defines a proxy |
| 188 */ |
| 189 bool get isProxy; |
| 190 |
| 191 /** |
| 185 * Return `true` if this class is defined by a typedef construct. | 192 * Return `true` if this class is defined by a typedef construct. |
| 186 * | 193 * |
| 187 * @return `true` if this class is defined by a typedef construct | 194 * @return `true` if this class is defined by a typedef construct |
| 188 */ | 195 */ |
| 189 bool get isTypedef; | 196 bool get isTypedef; |
| 190 | 197 |
| 191 /** | 198 /** |
| 192 * Return `true` if this class can validly be used as a mixin when defining an
other class. | 199 * Return `true` if this class can validly be used as a mixin when defining an
other class. |
| 193 * The behavior of this method is defined by the Dart Language Specification i
n section 9: | 200 * The behavior of this method is defined by the Dart Language Specification i
n section 9: |
| 194 * <blockquote>It is a compile-time error if a declared or derived mixin refer
s to super. It is a | 201 * <blockquote>It is a compile-time error if a declared or derived mixin refer
s to super. It is a |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 * | 408 * |
| 402 * | 409 * |
| 403 * Second, there are elements in the element model that do not have a name. Thes
e correspond to | 410 * Second, there are elements in the element model that do not have a name. Thes
e correspond to |
| 404 * unnamed functions and exist in order to more accurately represent the semanti
c structure of the | 411 * unnamed functions and exist in order to more accurately represent the semanti
c structure of the |
| 405 * program. | 412 * program. |
| 406 * | 413 * |
| 407 * @coverage dart.engine.element | 414 * @coverage dart.engine.element |
| 408 */ | 415 */ |
| 409 abstract class Element { | 416 abstract class Element { |
| 410 /** | 417 /** |
| 418 * An Unicode right arrow. |
| 419 */ |
| 420 static final String RIGHT_ARROW = " \u2192 "; |
| 421 |
| 422 /** |
| 411 * A comparator that can be used to sort elements by their name offset. Elemen
ts with a smaller | 423 * A comparator that can be used to sort elements by their name offset. Elemen
ts with a smaller |
| 412 * offset will be sorted to be before elements with a larger name offset. | 424 * offset will be sorted to be before elements with a larger name offset. |
| 413 */ | 425 */ |
| 414 static final Comparator<Element> SORT_BY_OFFSET = (Element firstElement, Eleme
nt secondElement) => firstElement.nameOffset - secondElement.nameOffset; | 426 static final Comparator<Element> SORT_BY_OFFSET = (Element firstElement, Eleme
nt secondElement) => firstElement.nameOffset - secondElement.nameOffset; |
| 415 | 427 |
| 416 /** | 428 /** |
| 417 * Use the given visitor to visit this element. | 429 * Use the given visitor to visit this element. |
| 418 * | 430 * |
| 419 * @param visitor the visitor that will visit this element | 431 * @param visitor the visitor that will visit this element |
| 420 * @return the value returned by the visitor as a result of visiting this elem
ent | 432 * @return the value returned by the visitor as a result of visiting this elem
ent |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 567 * @coverage dart.engine.element | 579 * @coverage dart.engine.element |
| 568 */ | 580 */ |
| 569 abstract class ElementAnnotation { | 581 abstract class ElementAnnotation { |
| 570 /** | 582 /** |
| 571 * Return the element representing the field, variable, or const constructor b
eing used as an | 583 * Return the element representing the field, variable, or const constructor b
eing used as an |
| 572 * annotation. | 584 * annotation. |
| 573 * | 585 * |
| 574 * @return the field, variable, or constructor being used as an annotation | 586 * @return the field, variable, or constructor being used as an annotation |
| 575 */ | 587 */ |
| 576 Element get element; | 588 Element get element; |
| 589 |
| 590 /** |
| 591 * Return `true` if this annotation marks the associated element as being depr
ecated. |
| 592 * |
| 593 * @return `true` if this annotation marks the associated element as being dep
recated |
| 594 */ |
| 595 bool get isDeprecated; |
| 596 |
| 597 /** |
| 598 * Return `true` if this annotation marks the associated method as being expec
ted to |
| 599 * override an inherited method. |
| 600 * |
| 601 * @return `true` if this annotation marks the associated method as overriding
another |
| 602 * method |
| 603 */ |
| 604 bool get isOverride; |
| 605 |
| 606 /** |
| 607 * Return `true` if this annotation marks the associated class as implementing
a proxy |
| 608 * object. |
| 609 * |
| 610 * @return `true` if this annotation marks the associated class as implementin
g a proxy |
| 611 * object |
| 612 */ |
| 613 bool get isProxy; |
| 577 } | 614 } |
| 578 | 615 |
| 579 /** | 616 /** |
| 580 * The enumeration `ElementKind` defines the various kinds of elements in the el
ement model. | 617 * The enumeration `ElementKind` defines the various kinds of elements in the el
ement model. |
| 581 * | 618 * |
| 582 * @coverage dart.engine.element | 619 * @coverage dart.engine.element |
| 583 */ | 620 */ |
| 584 class ElementKind extends Enum<ElementKind> { | 621 class ElementKind extends Enum<ElementKind> { |
| 585 static final ElementKind CLASS = new ElementKind('CLASS', 0, "class"); | 622 static final ElementKind CLASS = new ElementKind('CLASS', 0, "class"); |
| 586 | 623 |
| (...skipping 1508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2095 } | 2132 } |
| 2096 return null; | 2133 return null; |
| 2097 } | 2134 } |
| 2098 | 2135 |
| 2099 bool hasNonFinalField() { | 2136 bool hasNonFinalField() { |
| 2100 List<ClassElement> classesToVisit = new List<ClassElement>(); | 2137 List<ClassElement> classesToVisit = new List<ClassElement>(); |
| 2101 Set<ClassElement> visitedClasses = new Set<ClassElement>(); | 2138 Set<ClassElement> visitedClasses = new Set<ClassElement>(); |
| 2102 classesToVisit.add(this); | 2139 classesToVisit.add(this); |
| 2103 while (!classesToVisit.isEmpty) { | 2140 while (!classesToVisit.isEmpty) { |
| 2104 ClassElement currentElement = classesToVisit.removeAt(0); | 2141 ClassElement currentElement = classesToVisit.removeAt(0); |
| 2105 if (javaSetAdd(visitedClasses, currentElement)) { | 2142 if (visitedClasses.add(currentElement)) { |
| 2106 for (FieldElement field in currentElement.fields) { | 2143 for (FieldElement field in currentElement.fields) { |
| 2107 if (!field.isFinal && !field.isConst && !field.isStatic && !field.isSy
nthetic) { | 2144 if (!field.isFinal && !field.isConst && !field.isStatic && !field.isSy
nthetic) { |
| 2108 return true; | 2145 return true; |
| 2109 } | 2146 } |
| 2110 } | 2147 } |
| 2111 for (InterfaceType mixinType in currentElement.mixins) { | 2148 for (InterfaceType mixinType in currentElement.mixins) { |
| 2112 ClassElement mixinElement = mixinType.element; | 2149 ClassElement mixinElement = mixinType.element; |
| 2113 classesToVisit.add(mixinElement); | 2150 classesToVisit.add(mixinElement); |
| 2114 } | 2151 } |
| 2115 InterfaceType supertype = currentElement.supertype; | 2152 InterfaceType supertype = currentElement.supertype; |
| 2116 if (supertype != null) { | 2153 if (supertype != null) { |
| 2117 ClassElement superElement = supertype.element; | 2154 ClassElement superElement = supertype.element; |
| 2118 if (superElement != null) { | 2155 if (superElement != null) { |
| 2119 classesToVisit.add(superElement); | 2156 classesToVisit.add(superElement); |
| 2120 } | 2157 } |
| 2121 } | 2158 } |
| 2122 } | 2159 } |
| 2123 } | 2160 } |
| 2124 return false; | 2161 return false; |
| 2125 } | 2162 } |
| 2126 | 2163 |
| 2127 bool hasReferenceToSuper() => hasModifier(Modifier.REFERENCES_SUPER); | 2164 bool hasReferenceToSuper() => hasModifier(Modifier.REFERENCES_SUPER); |
| 2128 | 2165 |
| 2129 bool get isAbstract => hasModifier(Modifier.ABSTRACT); | 2166 bool get isAbstract => hasModifier(Modifier.ABSTRACT); |
| 2130 | 2167 |
| 2168 bool get isProxy { |
| 2169 for (ElementAnnotation annotation in metadata) { |
| 2170 if (annotation.isProxy) { |
| 2171 return true; |
| 2172 } |
| 2173 } |
| 2174 return false; |
| 2175 } |
| 2176 |
| 2131 bool get isTypedef => hasModifier(Modifier.TYPEDEF); | 2177 bool get isTypedef => hasModifier(Modifier.TYPEDEF); |
| 2132 | 2178 |
| 2133 bool get isValidMixin => hasModifier(Modifier.MIXIN); | 2179 bool get isValidMixin => hasModifier(Modifier.MIXIN); |
| 2134 | 2180 |
| 2135 PropertyAccessorElement lookUpGetter(String getterName, LibraryElement library
) { | 2181 PropertyAccessorElement lookUpGetter(String getterName, LibraryElement library
) { |
| 2136 Set<ClassElement> visitedClasses = new Set<ClassElement>(); | 2182 Set<ClassElement> visitedClasses = new Set<ClassElement>(); |
| 2137 ClassElement currentElement = this; | 2183 ClassElement currentElement = this; |
| 2138 while (currentElement != null && !visitedClasses.contains(currentElement)) { | 2184 while (currentElement != null && !visitedClasses.contains(currentElement)) { |
| 2139 javaSetAdd(visitedClasses, currentElement); | 2185 visitedClasses.add(currentElement); |
| 2140 PropertyAccessorElement element = currentElement.getGetter(getterName); | 2186 PropertyAccessorElement element = currentElement.getGetter(getterName); |
| 2141 if (element != null && element.isAccessibleIn(library)) { | 2187 if (element != null && element.isAccessibleIn(library)) { |
| 2142 return element; | 2188 return element; |
| 2143 } | 2189 } |
| 2144 for (InterfaceType mixin in currentElement.mixins) { | 2190 for (InterfaceType mixin in currentElement.mixins) { |
| 2145 ClassElement mixinElement = mixin.element; | 2191 ClassElement mixinElement = mixin.element; |
| 2146 if (mixinElement != null) { | 2192 if (mixinElement != null) { |
| 2147 element = mixinElement.getGetter(getterName); | 2193 element = mixinElement.getGetter(getterName); |
| 2148 if (element != null && element.isAccessibleIn(library)) { | 2194 if (element != null && element.isAccessibleIn(library)) { |
| 2149 return element; | 2195 return element; |
| 2150 } | 2196 } |
| 2151 } | 2197 } |
| 2152 } | 2198 } |
| 2153 InterfaceType supertype = currentElement.supertype; | 2199 InterfaceType supertype = currentElement.supertype; |
| 2154 if (supertype == null) { | 2200 if (supertype == null) { |
| 2155 return null; | 2201 return null; |
| 2156 } | 2202 } |
| 2157 currentElement = supertype.element; | 2203 currentElement = supertype.element; |
| 2158 } | 2204 } |
| 2159 return null; | 2205 return null; |
| 2160 } | 2206 } |
| 2161 | 2207 |
| 2162 MethodElement lookUpMethod(String methodName, LibraryElement library) { | 2208 MethodElement lookUpMethod(String methodName, LibraryElement library) { |
| 2163 Set<ClassElement> visitedClasses = new Set<ClassElement>(); | 2209 Set<ClassElement> visitedClasses = new Set<ClassElement>(); |
| 2164 ClassElement currentElement = this; | 2210 ClassElement currentElement = this; |
| 2165 while (currentElement != null && !visitedClasses.contains(currentElement)) { | 2211 while (currentElement != null && !visitedClasses.contains(currentElement)) { |
| 2166 javaSetAdd(visitedClasses, currentElement); | 2212 visitedClasses.add(currentElement); |
| 2167 MethodElement element = currentElement.getMethod(methodName); | 2213 MethodElement element = currentElement.getMethod(methodName); |
| 2168 if (element != null && element.isAccessibleIn(library)) { | 2214 if (element != null && element.isAccessibleIn(library)) { |
| 2169 return element; | 2215 return element; |
| 2170 } | 2216 } |
| 2171 for (InterfaceType mixin in currentElement.mixins) { | 2217 for (InterfaceType mixin in currentElement.mixins) { |
| 2172 ClassElement mixinElement = mixin.element; | 2218 ClassElement mixinElement = mixin.element; |
| 2173 if (mixinElement != null) { | 2219 if (mixinElement != null) { |
| 2174 element = mixinElement.getMethod(methodName); | 2220 element = mixinElement.getMethod(methodName); |
| 2175 if (element != null && element.isAccessibleIn(library)) { | 2221 if (element != null && element.isAccessibleIn(library)) { |
| 2176 return element; | 2222 return element; |
| 2177 } | 2223 } |
| 2178 } | 2224 } |
| 2179 } | 2225 } |
| 2180 InterfaceType supertype = currentElement.supertype; | 2226 InterfaceType supertype = currentElement.supertype; |
| 2181 if (supertype == null) { | 2227 if (supertype == null) { |
| 2182 return null; | 2228 return null; |
| 2183 } | 2229 } |
| 2184 currentElement = supertype.element; | 2230 currentElement = supertype.element; |
| 2185 } | 2231 } |
| 2186 return null; | 2232 return null; |
| 2187 } | 2233 } |
| 2188 | 2234 |
| 2189 PropertyAccessorElement lookUpSetter(String setterName, LibraryElement library
) { | 2235 PropertyAccessorElement lookUpSetter(String setterName, LibraryElement library
) { |
| 2190 Set<ClassElement> visitedClasses = new Set<ClassElement>(); | 2236 Set<ClassElement> visitedClasses = new Set<ClassElement>(); |
| 2191 ClassElement currentElement = this; | 2237 ClassElement currentElement = this; |
| 2192 while (currentElement != null && !visitedClasses.contains(currentElement)) { | 2238 while (currentElement != null && !visitedClasses.contains(currentElement)) { |
| 2193 javaSetAdd(visitedClasses, currentElement); | 2239 visitedClasses.add(currentElement); |
| 2194 PropertyAccessorElement element = currentElement.getSetter(setterName); | 2240 PropertyAccessorElement element = currentElement.getSetter(setterName); |
| 2195 if (element != null && element.isAccessibleIn(library)) { | 2241 if (element != null && element.isAccessibleIn(library)) { |
| 2196 return element; | 2242 return element; |
| 2197 } | 2243 } |
| 2198 for (InterfaceType mixin in currentElement.mixins) { | 2244 for (InterfaceType mixin in currentElement.mixins) { |
| 2199 ClassElement mixinElement = mixin.element; | 2245 ClassElement mixinElement = mixin.element; |
| 2200 if (mixinElement != null) { | 2246 if (mixinElement != null) { |
| 2201 element = mixinElement.getSetter(setterName); | 2247 element = mixinElement.getSetter(setterName); |
| 2202 if (element != null && element.isAccessibleIn(library)) { | 2248 if (element != null && element.isAccessibleIn(library)) { |
| 2203 return element; | 2249 return element; |
| (...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2879 * The element representing the field, variable, or constructor being used as
an annotation. | 2925 * The element representing the field, variable, or constructor being used as
an annotation. |
| 2880 */ | 2926 */ |
| 2881 Element _element; | 2927 Element _element; |
| 2882 | 2928 |
| 2883 /** | 2929 /** |
| 2884 * An empty array of annotations. | 2930 * An empty array of annotations. |
| 2885 */ | 2931 */ |
| 2886 static List<ElementAnnotationImpl> EMPTY_ARRAY = new List<ElementAnnotationImp
l>(0); | 2932 static List<ElementAnnotationImpl> EMPTY_ARRAY = new List<ElementAnnotationImp
l>(0); |
| 2887 | 2933 |
| 2888 /** | 2934 /** |
| 2935 * The name of the class used to mark an element as being deprecated. |
| 2936 */ |
| 2937 static String _DEPRECATED_CLASS_NAME = "Deprecated"; |
| 2938 |
| 2939 /** |
| 2940 * The name of the top-level variable used to mark an element as being depreca
ted. |
| 2941 */ |
| 2942 static String _DEPRECATED_VARIABLE_NAME = "deprecated"; |
| 2943 |
| 2944 /** |
| 2945 * The name of the top-level variable used to mark a method as being expected
to override an |
| 2946 * inherited method. |
| 2947 */ |
| 2948 static String _OVERRIDE_VARIABLE_NAME = "override"; |
| 2949 |
| 2950 /** |
| 2951 * The name of the top-level variable used to mark a class as implementing a p
roxy object. |
| 2952 */ |
| 2953 static String _PROXY_VARIABLE_NAME = "proxy"; |
| 2954 |
| 2955 /** |
| 2889 * Initialize a newly created annotation. | 2956 * Initialize a newly created annotation. |
| 2890 * | 2957 * |
| 2891 * @param element the element representing the field, variable, or constructor
being used as an | 2958 * @param element the element representing the field, variable, or constructor
being used as an |
| 2892 * annotation | 2959 * annotation |
| 2893 */ | 2960 */ |
| 2894 ElementAnnotationImpl(Element element) { | 2961 ElementAnnotationImpl(Element element) { |
| 2895 this._element = element; | 2962 this._element = element; |
| 2896 } | 2963 } |
| 2897 | 2964 |
| 2898 Element get element => _element; | 2965 Element get element => _element; |
| 2899 | 2966 |
| 2967 bool get isDeprecated { |
| 2968 if (_element != null) { |
| 2969 LibraryElement library = _element.library; |
| 2970 if (library != null && library.isDartCore) { |
| 2971 if (_element is ConstructorElement) { |
| 2972 ConstructorElement constructorElement = _element as ConstructorElement
; |
| 2973 if (constructorElement.enclosingElement.name == _DEPRECATED_CLASS_NAME
) { |
| 2974 return true; |
| 2975 } |
| 2976 } else if (_element is PropertyAccessorElement && _element.name == _DEPR
ECATED_VARIABLE_NAME) { |
| 2977 return true; |
| 2978 } |
| 2979 } |
| 2980 } |
| 2981 return false; |
| 2982 } |
| 2983 |
| 2984 bool get isOverride { |
| 2985 if (_element != null) { |
| 2986 LibraryElement library = _element.library; |
| 2987 if (library != null && library.isDartCore) { |
| 2988 if (_element is PropertyAccessorElement && _element.name == _OVERRIDE_VA
RIABLE_NAME) { |
| 2989 return true; |
| 2990 } |
| 2991 } |
| 2992 } |
| 2993 return false; |
| 2994 } |
| 2995 |
| 2996 bool get isProxy { |
| 2997 if (_element != null) { |
| 2998 LibraryElement library = _element.library; |
| 2999 if (library != null && library.isDartCore) { |
| 3000 if (_element is PropertyAccessorElement && _element.name == _PROXY_VARIA
BLE_NAME) { |
| 3001 return true; |
| 3002 } |
| 3003 } |
| 3004 } |
| 3005 return false; |
| 3006 } |
| 3007 |
| 2900 String toString() => "@${_element.toString()}"; | 3008 String toString() => "@${_element.toString()}"; |
| 2901 } | 3009 } |
| 2902 | 3010 |
| 2903 /** | 3011 /** |
| 2904 * The abstract class `ElementImpl` implements the behavior common to objects th
at implement | 3012 * The abstract class `ElementImpl` implements the behavior common to objects th
at implement |
| 2905 * an [Element]. | 3013 * an [Element]. |
| 2906 * | 3014 * |
| 2907 * @coverage dart.engine.element | 3015 * @coverage dart.engine.element |
| 2908 */ | 3016 */ |
| 2909 abstract class ElementImpl implements Element { | 3017 abstract class ElementImpl implements Element { |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3030 | 3138 |
| 3031 bool isAccessibleIn(LibraryElement library) { | 3139 bool isAccessibleIn(LibraryElement library) { |
| 3032 if (Identifier.isPrivateName(_name)) { | 3140 if (Identifier.isPrivateName(_name)) { |
| 3033 return library == this.library; | 3141 return library == this.library; |
| 3034 } | 3142 } |
| 3035 return true; | 3143 return true; |
| 3036 } | 3144 } |
| 3037 | 3145 |
| 3038 bool get isDeprecated { | 3146 bool get isDeprecated { |
| 3039 for (ElementAnnotation annotation in _metadata) { | 3147 for (ElementAnnotation annotation in _metadata) { |
| 3040 Element element = annotation.element; | 3148 if (annotation.isDeprecated) { |
| 3041 if (element != null) { | 3149 return true; |
| 3042 LibraryElement lib = element.library; | |
| 3043 if (lib != null && lib.isDartCore) { | |
| 3044 if (element is ConstructorElement) { | |
| 3045 ConstructorElement constructorElement = element as ConstructorElemen
t; | |
| 3046 if (constructorElement.enclosingElement.name == "Deprecated") { | |
| 3047 return true; | |
| 3048 } | |
| 3049 } else if (element is PropertyAccessorElement && element.name == "depr
ecated") { | |
| 3050 return true; | |
| 3051 } | |
| 3052 } | |
| 3053 } | 3150 } |
| 3054 } | 3151 } |
| 3055 return false; | 3152 return false; |
| 3056 } | 3153 } |
| 3057 | 3154 |
| 3058 bool get isSynthetic => hasModifier(Modifier.SYNTHETIC); | 3155 bool get isSynthetic => hasModifier(Modifier.SYNTHETIC); |
| 3059 | 3156 |
| 3060 /** | 3157 /** |
| 3061 * Set the metadata associate with this element to the given array of annotati
ons. | 3158 * Set the metadata associate with this element to the given array of annotati
ons. |
| 3062 * | 3159 * |
| (...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3571 builder.append("("); | 3668 builder.append("("); |
| 3572 int parameterCount = _parameters.length; | 3669 int parameterCount = _parameters.length; |
| 3573 for (int i = 0; i < parameterCount; i++) { | 3670 for (int i = 0; i < parameterCount; i++) { |
| 3574 if (i > 0) { | 3671 if (i > 0) { |
| 3575 builder.append(", "); | 3672 builder.append(", "); |
| 3576 } | 3673 } |
| 3577 (_parameters[i] as ParameterElementImpl).appendTo(builder); | 3674 (_parameters[i] as ParameterElementImpl).appendTo(builder); |
| 3578 } | 3675 } |
| 3579 builder.append(")"); | 3676 builder.append(")"); |
| 3580 if (_type != null) { | 3677 if (_type != null) { |
| 3581 builder.append(" -> "); | 3678 builder.append(Element.RIGHT_ARROW); |
| 3582 builder.append(_type.returnType); | 3679 builder.append(_type.returnType); |
| 3583 } | 3680 } |
| 3584 } | 3681 } |
| 3585 } | 3682 } |
| 3586 | 3683 |
| 3587 /** | 3684 /** |
| 3588 * Instances of the class `ExportElementImpl` implement an [ExportElement]. | 3685 * Instances of the class `ExportElementImpl` implement an [ExportElement]. |
| 3589 * | 3686 * |
| 3590 * @coverage dart.engine.element | 3687 * @coverage dart.engine.element |
| 3591 */ | 3688 */ |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3812 * Initialize a newly created function element to have no name and the given o
ffset. This is used | 3909 * Initialize a newly created function element to have no name and the given o
ffset. This is used |
| 3813 * for function expressions, which have no name. | 3910 * for function expressions, which have no name. |
| 3814 * | 3911 * |
| 3815 * @param nameOffset the offset of the name of this element in the file that c
ontains the | 3912 * @param nameOffset the offset of the name of this element in the file that c
ontains the |
| 3816 * declaration of this element | 3913 * declaration of this element |
| 3817 */ | 3914 */ |
| 3818 FunctionElementImpl.con2(int nameOffset) : super.con2("", nameOffset); | 3915 FunctionElementImpl.con2(int nameOffset) : super.con2("", nameOffset); |
| 3819 | 3916 |
| 3820 accept(ElementVisitor visitor) => visitor.visitFunctionElement(this); | 3917 accept(ElementVisitor visitor) => visitor.visitFunctionElement(this); |
| 3821 | 3918 |
| 3919 /** |
| 3920 * Treating the set of arrays defined in [ExecutableElementImpl] as one long a
rray, this |
| 3921 * returns the index position of the passed child in this [FunctionElement]. T
his gives a |
| 3922 * unique integer for each element, this is provided primarily for function el
ements that do not |
| 3923 * have a name (closures), which cannot use [Element#getNameOffset]. If there
is no such |
| 3924 * element, `-1` is returned. |
| 3925 * |
| 3926 * @param element the element to find and return an integer for, if there is n
o such element, |
| 3927 * `-1` is returned |
| 3928 */ |
| 3929 int getIndexPosition(Element element) { |
| 3930 List<FunctionElement> functions = this.functions; |
| 3931 List<LabelElement> labels = this.labels; |
| 3932 List<LocalVariableElement> localVariables = this.localVariables; |
| 3933 List<ParameterElement> parameters = this.parameters; |
| 3934 int count = 0; |
| 3935 for (int i = 0; i < functions.length; i++, count++) { |
| 3936 if (identical(element, functions[i])) { |
| 3937 return count; |
| 3938 } |
| 3939 } |
| 3940 for (int i = 0; i < labels.length; i++, count++) { |
| 3941 if (identical(element, labels[i])) { |
| 3942 return count; |
| 3943 } |
| 3944 } |
| 3945 for (int i = 0; i < localVariables.length; i++, count++) { |
| 3946 if (identical(element, localVariables[i])) { |
| 3947 return count; |
| 3948 } |
| 3949 } |
| 3950 for (int i = 0; i < parameters.length; i++, count++) { |
| 3951 if (identical(element, parameters[i])) { |
| 3952 return count; |
| 3953 } |
| 3954 } |
| 3955 return -1; |
| 3956 } |
| 3957 |
| 3822 ElementKind get kind => ElementKind.FUNCTION; | 3958 ElementKind get kind => ElementKind.FUNCTION; |
| 3823 | 3959 |
| 3824 SourceRange get visibleRange { | 3960 SourceRange get visibleRange { |
| 3825 if (_visibleRangeLength < 0) { | 3961 if (_visibleRangeLength < 0) { |
| 3826 return null; | 3962 return null; |
| 3827 } | 3963 } |
| 3828 return new SourceRange(_visibleRangeOffset, _visibleRangeLength); | 3964 return new SourceRange(_visibleRangeOffset, _visibleRangeLength); |
| 3829 } | 3965 } |
| 3830 | 3966 |
| 3831 bool get isStatic => enclosingElement is CompilationUnitElement; | 3967 bool get isStatic => enclosingElement is CompilationUnitElement; |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4010 builder.append("("); | 4146 builder.append("("); |
| 4011 int parameterCount = _parameters.length; | 4147 int parameterCount = _parameters.length; |
| 4012 for (int i = 0; i < parameterCount; i++) { | 4148 for (int i = 0; i < parameterCount; i++) { |
| 4013 if (i > 0) { | 4149 if (i > 0) { |
| 4014 builder.append(", "); | 4150 builder.append(", "); |
| 4015 } | 4151 } |
| 4016 (_parameters[i] as ParameterElementImpl).appendTo(builder); | 4152 (_parameters[i] as ParameterElementImpl).appendTo(builder); |
| 4017 } | 4153 } |
| 4018 builder.append(")"); | 4154 builder.append(")"); |
| 4019 if (_type != null) { | 4155 if (_type != null) { |
| 4020 builder.append(" -> "); | 4156 builder.append(Element.RIGHT_ARROW); |
| 4021 builder.append(_type.returnType); | 4157 builder.append(_type.returnType); |
| 4022 } | 4158 } |
| 4023 } | 4159 } |
| 4024 } | 4160 } |
| 4025 | 4161 |
| 4026 /** | 4162 /** |
| 4027 * Instances of the class `HideElementCombinatorImpl` implement a | 4163 * Instances of the class `HideElementCombinatorImpl` implement a |
| 4028 * [HideElementCombinator]. | 4164 * [HideElementCombinator]. |
| 4029 * | 4165 * |
| 4030 * @coverage dart.engine.element | 4166 * @coverage dart.engine.element |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4364 | 4500 |
| 4365 /** | 4501 /** |
| 4366 * Determine if the given library is up to date with respect to the given time
stamp. | 4502 * Determine if the given library is up to date with respect to the given time
stamp. |
| 4367 * | 4503 * |
| 4368 * @param library the library to process | 4504 * @param library the library to process |
| 4369 * @param timeStamp the time stamp to check against | 4505 * @param timeStamp the time stamp to check against |
| 4370 * @param visitedLibraries the set of visited libraries | 4506 * @param visitedLibraries the set of visited libraries |
| 4371 */ | 4507 */ |
| 4372 static bool isUpToDate(LibraryElement library, int timeStamp, Set<LibraryEleme
nt> visitedLibraries) { | 4508 static bool isUpToDate(LibraryElement library, int timeStamp, Set<LibraryEleme
nt> visitedLibraries) { |
| 4373 if (!visitedLibraries.contains(library)) { | 4509 if (!visitedLibraries.contains(library)) { |
| 4374 javaSetAdd(visitedLibraries, library); | 4510 visitedLibraries.add(library); |
| 4375 if (timeStamp < library.definingCompilationUnit.source.modificationStamp)
{ | 4511 if (timeStamp < library.definingCompilationUnit.source.modificationStamp)
{ |
| 4376 return false; | 4512 return false; |
| 4377 } | 4513 } |
| 4378 for (CompilationUnitElement element in library.parts) { | 4514 for (CompilationUnitElement element in library.parts) { |
| 4379 if (timeStamp < element.source.modificationStamp) { | 4515 if (timeStamp < element.source.modificationStamp) { |
| 4380 return false; | 4516 return false; |
| 4381 } | 4517 } |
| 4382 } | 4518 } |
| 4383 for (LibraryElement importedLibrary in library.importedLibraries) { | 4519 for (LibraryElement importedLibrary in library.importedLibraries) { |
| 4384 if (!isUpToDate(importedLibrary, timeStamp, visitedLibraries)) { | 4520 if (!isUpToDate(importedLibrary, timeStamp, visitedLibraries)) { |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4465 | 4601 |
| 4466 CompilationUnitElement get definingCompilationUnit => _definingCompilationUnit
; | 4602 CompilationUnitElement get definingCompilationUnit => _definingCompilationUnit
; |
| 4467 | 4603 |
| 4468 FunctionElement get entryPoint => _entryPoint; | 4604 FunctionElement get entryPoint => _entryPoint; |
| 4469 | 4605 |
| 4470 List<LibraryElement> get exportedLibraries { | 4606 List<LibraryElement> get exportedLibraries { |
| 4471 Set<LibraryElement> libraries = new Set<LibraryElement>(); | 4607 Set<LibraryElement> libraries = new Set<LibraryElement>(); |
| 4472 for (ExportElement element in _exports) { | 4608 for (ExportElement element in _exports) { |
| 4473 LibraryElement library = element.exportedLibrary; | 4609 LibraryElement library = element.exportedLibrary; |
| 4474 if (library != null) { | 4610 if (library != null) { |
| 4475 javaSetAdd(libraries, library); | 4611 libraries.add(library); |
| 4476 } | 4612 } |
| 4477 } | 4613 } |
| 4478 return new List.from(libraries); | 4614 return new List.from(libraries); |
| 4479 } | 4615 } |
| 4480 | 4616 |
| 4481 List<ExportElement> get exports => _exports; | 4617 List<ExportElement> get exports => _exports; |
| 4482 | 4618 |
| 4483 List<LibraryElement> get importedLibraries { | 4619 List<LibraryElement> get importedLibraries { |
| 4484 Set<LibraryElement> libraries = new Set<LibraryElement>(); | 4620 Set<LibraryElement> libraries = new Set<LibraryElement>(); |
| 4485 for (ImportElement element in _imports) { | 4621 for (ImportElement element in _imports) { |
| 4486 LibraryElement library = element.importedLibrary; | 4622 LibraryElement library = element.importedLibrary; |
| 4487 if (library != null) { | 4623 if (library != null) { |
| 4488 javaSetAdd(libraries, library); | 4624 libraries.add(library); |
| 4489 } | 4625 } |
| 4490 } | 4626 } |
| 4491 return new List.from(libraries); | 4627 return new List.from(libraries); |
| 4492 } | 4628 } |
| 4493 | 4629 |
| 4494 List<ImportElement> get imports => _imports; | 4630 List<ImportElement> get imports => _imports; |
| 4495 | 4631 |
| 4496 ElementKind get kind => ElementKind.LIBRARY; | 4632 ElementKind get kind => ElementKind.LIBRARY; |
| 4497 | 4633 |
| 4498 LibraryElement get library => this; | 4634 LibraryElement get library => this; |
| 4499 | 4635 |
| 4500 List<CompilationUnitElement> get parts => _parts; | 4636 List<CompilationUnitElement> get parts => _parts; |
| 4501 | 4637 |
| 4502 List<PrefixElement> get prefixes { | 4638 List<PrefixElement> get prefixes { |
| 4503 Set<PrefixElement> prefixes = new Set<PrefixElement>(); | 4639 Set<PrefixElement> prefixes = new Set<PrefixElement>(); |
| 4504 for (ImportElement element in _imports) { | 4640 for (ImportElement element in _imports) { |
| 4505 PrefixElement prefix = element.prefix; | 4641 PrefixElement prefix = element.prefix; |
| 4506 if (prefix != null) { | 4642 if (prefix != null) { |
| 4507 javaSetAdd(prefixes, prefix); | 4643 prefixes.add(prefix); |
| 4508 } | 4644 } |
| 4509 } | 4645 } |
| 4510 return new List.from(prefixes); | 4646 return new List.from(prefixes); |
| 4511 } | 4647 } |
| 4512 | 4648 |
| 4513 Source get source { | 4649 Source get source { |
| 4514 if (_definingCompilationUnit == null) { | 4650 if (_definingCompilationUnit == null) { |
| 4515 return null; | 4651 return null; |
| 4516 } | 4652 } |
| 4517 return _definingCompilationUnit.source; | 4653 return _definingCompilationUnit.source; |
| (...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4889 /** | 5025 /** |
| 4890 * Add the given element to the list of elements. If the element is a multiply
-defined element, | 5026 * Add the given element to the list of elements. If the element is a multiply
-defined element, |
| 4891 * add all of the conflicting elements that it represents. | 5027 * add all of the conflicting elements that it represents. |
| 4892 * | 5028 * |
| 4893 * @param elements the list to which the element(s) are to be added | 5029 * @param elements the list to which the element(s) are to be added |
| 4894 * @param element the element(s) to be added | 5030 * @param element the element(s) to be added |
| 4895 */ | 5031 */ |
| 4896 static void add(Set<Element> elements, Element element) { | 5032 static void add(Set<Element> elements, Element element) { |
| 4897 if (element is MultiplyDefinedElementImpl) { | 5033 if (element is MultiplyDefinedElementImpl) { |
| 4898 for (Element conflictingElement in (element as MultiplyDefinedElementImpl)
._conflictingElements) { | 5034 for (Element conflictingElement in (element as MultiplyDefinedElementImpl)
._conflictingElements) { |
| 4899 javaSetAdd(elements, conflictingElement); | 5035 elements.add(conflictingElement); |
| 4900 } | 5036 } |
| 4901 } else { | 5037 } else { |
| 4902 javaSetAdd(elements, element); | 5038 elements.add(element); |
| 4903 } | 5039 } |
| 4904 } | 5040 } |
| 4905 | 5041 |
| 4906 /** | 5042 /** |
| 4907 * Use the given elements to construct an array of conflicting elements. If ei
ther of the given | 5043 * Use the given elements to construct an array of conflicting elements. If ei
ther of the given |
| 4908 * elements are multiply-defined elements then the conflicting elements they r
epresent will be | 5044 * elements are multiply-defined elements then the conflicting elements they r
epresent will be |
| 4909 * included in the array. Otherwise, the element itself will be included. | 5045 * included in the array. Otherwise, the element itself will be included. |
| 4910 * | 5046 * |
| 4911 * @param firstElement the first element to be included | 5047 * @param firstElement the first element to be included |
| 4912 * @param secondElement the second element to be included | 5048 * @param secondElement the second element to be included |
| (...skipping 886 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5799 builder.append("("); | 5935 builder.append("("); |
| 5800 int parameterCount = parameters.length; | 5936 int parameterCount = parameters.length; |
| 5801 for (int i = 0; i < parameterCount; i++) { | 5937 for (int i = 0; i < parameterCount; i++) { |
| 5802 if (i > 0) { | 5938 if (i > 0) { |
| 5803 builder.append(", "); | 5939 builder.append(", "); |
| 5804 } | 5940 } |
| 5805 builder.append(parameters[i]).toString(); | 5941 builder.append(parameters[i]).toString(); |
| 5806 } | 5942 } |
| 5807 builder.append(")"); | 5943 builder.append(")"); |
| 5808 if (type != null) { | 5944 if (type != null) { |
| 5809 builder.append(" -> "); | 5945 builder.append(Element.RIGHT_ARROW); |
| 5810 builder.append(type.returnType); | 5946 builder.append(type.returnType); |
| 5811 } | 5947 } |
| 5812 return builder.toString(); | 5948 return builder.toString(); |
| 5813 } | 5949 } |
| 5814 | 5950 |
| 5815 InterfaceType get definingType => super.definingType as InterfaceType; | 5951 InterfaceType get definingType => super.definingType as InterfaceType; |
| 5816 } | 5952 } |
| 5817 | 5953 |
| 5818 /** | 5954 /** |
| 5819 * The abstract class `ExecutableMember` defines the behavior common to members
that represent | 5955 * The abstract class `ExecutableMember` defines the behavior common to members
that represent |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5866 void visitChildren(ElementVisitor visitor) { | 6002 void visitChildren(ElementVisitor visitor) { |
| 5867 super.visitChildren(visitor); | 6003 super.visitChildren(visitor); |
| 5868 safelyVisitChildren(baseElement.functions, visitor); | 6004 safelyVisitChildren(baseElement.functions, visitor); |
| 5869 safelyVisitChildren(labels, visitor); | 6005 safelyVisitChildren(labels, visitor); |
| 5870 safelyVisitChildren(baseElement.localVariables, visitor); | 6006 safelyVisitChildren(baseElement.localVariables, visitor); |
| 5871 safelyVisitChildren(parameters, visitor); | 6007 safelyVisitChildren(parameters, visitor); |
| 5872 } | 6008 } |
| 5873 } | 6009 } |
| 5874 | 6010 |
| 5875 /** | 6011 /** |
| 6012 * Instances of the class `FieldFormalParameterMember` represent a parameter ele
ment defined |
| 6013 * in a parameterized type where the values of the type parameters are known. |
| 6014 */ |
| 6015 class FieldFormalParameterMember extends ParameterMember implements FieldFormalP
arameterElement { |
| 6016 /** |
| 6017 * Initialize a newly created element to represent a parameter of the given pa
rameterized type. |
| 6018 * |
| 6019 * @param baseElement the element on which the parameterized element was creat
ed |
| 6020 * @param definingType the type in which the element is defined |
| 6021 */ |
| 6022 FieldFormalParameterMember(FieldFormalParameterElement baseElement, Parameteri
zedType definingType) : super(baseElement, definingType); |
| 6023 |
| 6024 accept(ElementVisitor visitor) => visitor.visitFieldFormalParameterElement(thi
s); |
| 6025 |
| 6026 FieldElement get field => (baseElement as FieldFormalParameterElement).field; |
| 6027 } |
| 6028 |
| 6029 /** |
| 5876 * Instances of the class `FieldMember` represent a field element defined in a p
arameterized | 6030 * Instances of the class `FieldMember` represent a field element defined in a p
arameterized |
| 5877 * type where the values of the type parameters are known. | 6031 * type where the values of the type parameters are known. |
| 5878 */ | 6032 */ |
| 5879 class FieldMember extends VariableMember implements FieldElement { | 6033 class FieldMember extends VariableMember implements FieldElement { |
| 5880 /** | 6034 /** |
| 5881 * If the given field's type is different when any type parameters from the de
fining type's | 6035 * If the given field's type is different when any type parameters from the de
fining type's |
| 5882 * declaration are replaced with the actual type arguments from the defining t
ype, create a field | 6036 * declaration are replaced with the actual type arguments from the defining t
ype, create a field |
| 5883 * member representing the given field. Return the member that was created, or
the base field if | 6037 * member representing the given field. Return the member that was created, or
the base field if |
| 5884 * no member was created. | 6038 * no member was created. |
| 5885 * | 6039 * |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6112 builder.append("("); | 6266 builder.append("("); |
| 6113 int parameterCount = parameters.length; | 6267 int parameterCount = parameters.length; |
| 6114 for (int i = 0; i < parameterCount; i++) { | 6268 for (int i = 0; i < parameterCount; i++) { |
| 6115 if (i > 0) { | 6269 if (i > 0) { |
| 6116 builder.append(", "); | 6270 builder.append(", "); |
| 6117 } | 6271 } |
| 6118 builder.append(parameters[i]).toString(); | 6272 builder.append(parameters[i]).toString(); |
| 6119 } | 6273 } |
| 6120 builder.append(")"); | 6274 builder.append(")"); |
| 6121 if (type != null) { | 6275 if (type != null) { |
| 6122 builder.append(" -> "); | 6276 builder.append(Element.RIGHT_ARROW); |
| 6123 builder.append(type.returnType); | 6277 builder.append(type.returnType); |
| 6124 } | 6278 } |
| 6125 return builder.toString(); | 6279 return builder.toString(); |
| 6126 } | 6280 } |
| 6127 } | 6281 } |
| 6128 | 6282 |
| 6129 /** | 6283 /** |
| 6130 * Instances of the class `ParameterMember` represent a parameter element define
d in a | 6284 * Instances of the class `ParameterMember` represent a parameter element define
d in a |
| 6131 * parameterized type where the values of the type parameters are known. | 6285 * parameterized type where the values of the type parameters are known. |
| 6132 */ | 6286 */ |
| 6133 class ParameterMember extends VariableMember implements ParameterElement { | 6287 class ParameterMember extends VariableMember implements ParameterElement { |
| 6134 /** | 6288 /** |
| 6135 * If the given parameter's type is different when any type parameters from th
e defining type's | 6289 * If the given parameter's type is different when any type parameters from th
e defining type's |
| 6136 * declaration are replaced with the actual type arguments from the defining t
ype, create a | 6290 * declaration are replaced with the actual type arguments from the defining t
ype, create a |
| 6137 * parameter member representing the given parameter. Return the member that w
as created, or the | 6291 * parameter member representing the given parameter. Return the member that w
as created, or the |
| 6138 * base parameter if no member was created. | 6292 * base parameter if no member was created. |
| 6139 * | 6293 * |
| 6140 * @param baseParameter the base parameter for which a member might be created | 6294 * @param baseParameter the base parameter for which a member might be created |
| 6141 * @param definingType the type defining the parameters and arguments to be us
ed in the | 6295 * @param definingType the type defining the parameters and arguments to be us
ed in the |
| 6142 * substitution | 6296 * substitution |
| 6143 * @return the parameter element that will return the correctly substituted ty
pes | 6297 * @return the parameter element that will return the correctly substituted ty
pes |
| 6144 */ | 6298 */ |
| 6145 static ParameterElement from(ParameterElement baseParameter, ParameterizedType
definingType) { | 6299 static ParameterElement from(ParameterElement baseParameter, ParameterizedType
definingType) { |
| 6146 if (baseParameter == null || definingType.typeArguments.length == 0) { | 6300 if (baseParameter == null || definingType.typeArguments.length == 0) { |
| 6147 return baseParameter; | 6301 return baseParameter; |
| 6148 } | 6302 } |
| 6149 if (baseParameter is! FieldFormalParameterElement) { | 6303 bool isFieldFormal = baseParameter is FieldFormalParameterElement; |
| 6304 if (!isFieldFormal) { |
| 6150 Type2 baseType = baseParameter.type; | 6305 Type2 baseType = baseParameter.type; |
| 6151 List<Type2> argumentTypes = definingType.typeArguments; | 6306 List<Type2> argumentTypes = definingType.typeArguments; |
| 6152 List<Type2> parameterTypes = TypeParameterTypeImpl.getTypes(definingType.t
ypeParameters); | 6307 List<Type2> parameterTypes = TypeParameterTypeImpl.getTypes(definingType.t
ypeParameters); |
| 6153 Type2 substitutedType = baseType.substitute2(argumentTypes, parameterTypes
); | 6308 Type2 substitutedType = baseType.substitute2(argumentTypes, parameterTypes
); |
| 6154 if (baseType == substitutedType) { | 6309 if (baseType == substitutedType) { |
| 6155 return baseParameter; | 6310 return baseParameter; |
| 6156 } | 6311 } |
| 6157 } | 6312 } |
| 6313 if (isFieldFormal) { |
| 6314 return new FieldFormalParameterMember(baseParameter as FieldFormalParamete
rElement, definingType); |
| 6315 } |
| 6158 return new ParameterMember(baseParameter, definingType); | 6316 return new ParameterMember(baseParameter, definingType); |
| 6159 } | 6317 } |
| 6160 | 6318 |
| 6161 /** | 6319 /** |
| 6162 * Initialize a newly created element to represent a parameter of the given pa
rameterized type. | 6320 * Initialize a newly created element to represent a parameter of the given pa
rameterized type. |
| 6163 * | 6321 * |
| 6164 * @param baseElement the element on which the parameterized element was creat
ed | 6322 * @param baseElement the element on which the parameterized element was creat
ed |
| 6165 * @param definingType the type in which the element is defined | 6323 * @param definingType the type in which the element is defined |
| 6166 */ | 6324 */ |
| 6167 ParameterMember(ParameterElement baseElement, ParameterizedType definingType)
: super(baseElement, definingType); | 6325 ParameterMember(ParameterElement baseElement, ParameterizedType definingType)
: super(baseElement, definingType); |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6317 builder.append("("); | 6475 builder.append("("); |
| 6318 int parameterCount = parameters.length; | 6476 int parameterCount = parameters.length; |
| 6319 for (int i = 0; i < parameterCount; i++) { | 6477 for (int i = 0; i < parameterCount; i++) { |
| 6320 if (i > 0) { | 6478 if (i > 0) { |
| 6321 builder.append(", "); | 6479 builder.append(", "); |
| 6322 } | 6480 } |
| 6323 builder.append(parameters[i]).toString(); | 6481 builder.append(parameters[i]).toString(); |
| 6324 } | 6482 } |
| 6325 builder.append(")"); | 6483 builder.append(")"); |
| 6326 if (type != null) { | 6484 if (type != null) { |
| 6327 builder.append(" -> "); | 6485 builder.append(Element.RIGHT_ARROW); |
| 6328 builder.append(type.returnType); | 6486 builder.append(type.returnType); |
| 6329 } | 6487 } |
| 6330 return builder.toString(); | 6488 return builder.toString(); |
| 6331 } | 6489 } |
| 6332 | 6490 |
| 6333 InterfaceType get definingType => super.definingType as InterfaceType; | 6491 InterfaceType get definingType => super.definingType as InterfaceType; |
| 6334 } | 6492 } |
| 6335 | 6493 |
| 6336 /** | 6494 /** |
| 6337 * The abstract class `VariableMember` defines the behavior common to members th
at represent a | 6495 * The abstract class `VariableMember` defines the behavior common to members th
at represent a |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6379 | 6537 |
| 6380 /** | 6538 /** |
| 6381 * Prevent the creation of instances of this class. | 6539 * Prevent the creation of instances of this class. |
| 6382 */ | 6540 */ |
| 6383 BottomTypeImpl() : super(null, "<bottom>"); | 6541 BottomTypeImpl() : super(null, "<bottom>"); |
| 6384 | 6542 |
| 6385 bool operator ==(Object object) => identical(object, this); | 6543 bool operator ==(Object object) => identical(object, this); |
| 6386 | 6544 |
| 6387 bool get isBottom => true; | 6545 bool get isBottom => true; |
| 6388 | 6546 |
| 6389 bool isMoreSpecificThan3(Type2 type, bool withDynamic) => true; | |
| 6390 | |
| 6391 bool isSubtypeOf(Type2 type) => true; | |
| 6392 | |
| 6393 bool isSupertypeOf(Type2 type) => false; | 6547 bool isSupertypeOf(Type2 type) => false; |
| 6394 | 6548 |
| 6395 BottomTypeImpl substitute2(List<Type2> argumentTypes, List<Type2> parameterTyp
es) => this; | 6549 BottomTypeImpl substitute2(List<Type2> argumentTypes, List<Type2> parameterTyp
es) => this; |
| 6550 |
| 6551 bool internalIsMoreSpecificThan(Type2 type, bool withDynamic, Set<TypeImpl_Typ
ePair> visitedTypePairs) => true; |
| 6552 |
| 6553 bool internalIsSubtypeOf(Type2 type, Set<TypeImpl_TypePair> visitedTypePairs)
=> true; |
| 6396 } | 6554 } |
| 6397 | 6555 |
| 6398 /** | 6556 /** |
| 6399 * The unique instance of the class `DynamicTypeImpl` implements the type `dynam
ic`. | 6557 * The unique instance of the class `DynamicTypeImpl` implements the type `dynam
ic`. |
| 6400 * | 6558 * |
| 6401 * @coverage dart.engine.type | 6559 * @coverage dart.engine.type |
| 6402 */ | 6560 */ |
| 6403 class DynamicTypeImpl extends TypeImpl { | 6561 class DynamicTypeImpl extends TypeImpl { |
| 6404 /** | 6562 /** |
| 6405 * The unique instance of this class. | 6563 * The unique instance of this class. |
| 6406 */ | 6564 */ |
| 6407 static final DynamicTypeImpl instance = new DynamicTypeImpl(); | 6565 static final DynamicTypeImpl instance = new DynamicTypeImpl(); |
| 6408 | 6566 |
| 6409 /** | 6567 /** |
| 6410 * Prevent the creation of instances of this class. | 6568 * Prevent the creation of instances of this class. |
| 6411 */ | 6569 */ |
| 6412 DynamicTypeImpl() : super(new DynamicElementImpl(), Keyword.DYNAMIC.syntax) { | 6570 DynamicTypeImpl() : super(new DynamicElementImpl(), Keyword.DYNAMIC.syntax) { |
| 6413 (element as DynamicElementImpl).type = this; | 6571 (element as DynamicElementImpl).type = this; |
| 6414 } | 6572 } |
| 6415 | 6573 |
| 6416 bool operator ==(Object object) => object is DynamicTypeImpl; | 6574 bool operator ==(Object object) => object is DynamicTypeImpl; |
| 6417 | 6575 |
| 6418 bool get isDynamic => true; | 6576 bool get isDynamic => true; |
| 6419 | 6577 |
| 6420 bool isMoreSpecificThan3(Type2 type, bool withDynamic) { | |
| 6421 if (identical(this, type)) { | |
| 6422 return true; | |
| 6423 } | |
| 6424 return withDynamic; | |
| 6425 } | |
| 6426 | |
| 6427 bool isSubtypeOf(Type2 type) => true; | |
| 6428 | |
| 6429 bool isSupertypeOf(Type2 type) => true; | 6578 bool isSupertypeOf(Type2 type) => true; |
| 6430 | 6579 |
| 6431 Type2 substitute2(List<Type2> argumentTypes, List<Type2> parameterTypes) { | 6580 Type2 substitute2(List<Type2> argumentTypes, List<Type2> parameterTypes) { |
| 6432 int length = parameterTypes.length; | 6581 int length = parameterTypes.length; |
| 6433 for (int i = 0; i < length; i++) { | 6582 for (int i = 0; i < length; i++) { |
| 6434 if (parameterTypes[i] == this) { | 6583 if (parameterTypes[i] == this) { |
| 6435 return argumentTypes[i]; | 6584 return argumentTypes[i]; |
| 6436 } | 6585 } |
| 6437 } | 6586 } |
| 6438 return this; | 6587 return this; |
| 6439 } | 6588 } |
| 6589 |
| 6590 bool internalIsMoreSpecificThan(Type2 type, bool withDynamic, Set<TypeImpl_Typ
ePair> visitedTypePairs) { |
| 6591 if (identical(this, type)) { |
| 6592 return true; |
| 6593 } |
| 6594 return withDynamic; |
| 6595 } |
| 6596 |
| 6597 bool internalIsSubtypeOf(Type2 type, Set<TypeImpl_TypePair> visitedTypePairs)
=> true; |
| 6440 } | 6598 } |
| 6441 | 6599 |
| 6442 /** | 6600 /** |
| 6443 * Instances of the class `FunctionTypeImpl` defines the behavior common to obje
cts | 6601 * Instances of the class `FunctionTypeImpl` defines the behavior common to obje
cts |
| 6444 * representing the type of a function, method, constructor, getter, or setter. | 6602 * representing the type of a function, method, constructor, getter, or setter. |
| 6445 * | 6603 * |
| 6446 * @coverage dart.engine.type | 6604 * @coverage dart.engine.type |
| 6447 */ | 6605 */ |
| 6448 class FunctionTypeImpl extends TypeImpl implements FunctionType { | 6606 class FunctionTypeImpl extends TypeImpl implements FunctionType { |
| 6449 /** | 6607 /** |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6550 } else { | 6708 } else { |
| 6551 needsComma = true; | 6709 needsComma = true; |
| 6552 } | 6710 } |
| 6553 builder.append(entry.getKey()); | 6711 builder.append(entry.getKey()); |
| 6554 builder.append(": "); | 6712 builder.append(": "); |
| 6555 builder.append(entry.getValue().displayName); | 6713 builder.append(entry.getValue().displayName); |
| 6556 } | 6714 } |
| 6557 builder.append("}"); | 6715 builder.append("}"); |
| 6558 needsComma = true; | 6716 needsComma = true; |
| 6559 } | 6717 } |
| 6560 builder.append(") -> "); | 6718 builder.append(")"); |
| 6719 builder.append(Element.RIGHT_ARROW); |
| 6561 if (returnType == null) { | 6720 if (returnType == null) { |
| 6562 builder.append("null"); | 6721 builder.append("null"); |
| 6563 } else { | 6722 } else { |
| 6564 builder.append(returnType.displayName); | 6723 builder.append(returnType.displayName); |
| 6565 } | 6724 } |
| 6566 name = builder.toString(); | 6725 name = builder.toString(); |
| 6567 } | 6726 } |
| 6568 return name; | 6727 return name; |
| 6569 } | 6728 } |
| 6570 | 6729 |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6649 } | 6808 } |
| 6650 | 6809 |
| 6651 int get hashCode { | 6810 int get hashCode { |
| 6652 Element element = this.element; | 6811 Element element = this.element; |
| 6653 if (element == null) { | 6812 if (element == null) { |
| 6654 return 0; | 6813 return 0; |
| 6655 } | 6814 } |
| 6656 return element.hashCode; | 6815 return element.hashCode; |
| 6657 } | 6816 } |
| 6658 | 6817 |
| 6659 bool isAssignableTo(Type2 type) => this.isSubtypeOf(type); | 6818 bool internalIsMoreSpecificThan(Type2 type, bool withDynamic, Set<TypeImpl_Typ
ePair> visitedTypePairs) { |
| 6660 | |
| 6661 bool isMoreSpecificThan3(Type2 type, bool withDynamic) { | |
| 6662 if (type == null) { | 6819 if (type == null) { |
| 6663 return false; | 6820 return false; |
| 6664 } else if (identical(this, type) || type.isDynamic || type.isDartCoreFunctio
n || type.isObject) { | 6821 } else if (identical(this, type) || type.isDynamic || type.isDartCoreFunctio
n || type.isObject) { |
| 6665 return true; | 6822 return true; |
| 6666 } else if (type is! FunctionType) { | 6823 } else if (type is! FunctionType) { |
| 6667 return false; | 6824 return false; |
| 6668 } else if (this == type) { | 6825 } else if (this == type) { |
| 6669 return true; | 6826 return true; |
| 6670 } | 6827 } |
| 6671 FunctionType t = this; | 6828 FunctionType t = this; |
| 6672 FunctionType s = type as FunctionType; | 6829 FunctionType s = type as FunctionType; |
| 6673 List<Type2> tTypes = t.normalParameterTypes; | 6830 List<Type2> tTypes = t.normalParameterTypes; |
| 6674 List<Type2> tOpTypes = t.optionalParameterTypes; | 6831 List<Type2> tOpTypes = t.optionalParameterTypes; |
| 6675 List<Type2> sTypes = s.normalParameterTypes; | 6832 List<Type2> sTypes = s.normalParameterTypes; |
| 6676 List<Type2> sOpTypes = s.optionalParameterTypes; | 6833 List<Type2> sOpTypes = s.optionalParameterTypes; |
| 6677 if ((sOpTypes.length > 0 && t.namedParameterTypes.length > 0) || (tOpTypes.l
ength > 0 && s.namedParameterTypes.length > 0)) { | 6834 if ((sOpTypes.length > 0 && t.namedParameterTypes.length > 0) || (tOpTypes.l
ength > 0 && s.namedParameterTypes.length > 0)) { |
| 6678 return false; | 6835 return false; |
| 6679 } | 6836 } |
| 6680 if (t.namedParameterTypes.length > 0) { | 6837 if (t.namedParameterTypes.length > 0) { |
| 6681 if (t.normalParameterTypes.length != s.normalParameterTypes.length) { | 6838 if (t.normalParameterTypes.length != s.normalParameterTypes.length) { |
| 6682 return false; | 6839 return false; |
| 6683 } else if (t.normalParameterTypes.length > 0) { | 6840 } else if (t.normalParameterTypes.length > 0) { |
| 6684 for (int i = 0; i < tTypes.length; i++) { | 6841 for (int i = 0; i < tTypes.length; i++) { |
| 6685 if (!tTypes[i].isMoreSpecificThan3(sTypes[i], withDynamic)) { | 6842 if (!(tTypes[i] as TypeImpl).isMoreSpecificThan3(sTypes[i], withDynami
c, visitedTypePairs)) { |
| 6686 return false; | 6843 return false; |
| 6687 } | 6844 } |
| 6688 } | 6845 } |
| 6689 } | 6846 } |
| 6690 Map<String, Type2> namedTypesT = t.namedParameterTypes; | 6847 Map<String, Type2> namedTypesT = t.namedParameterTypes; |
| 6691 Map<String, Type2> namedTypesS = s.namedParameterTypes; | 6848 Map<String, Type2> namedTypesS = s.namedParameterTypes; |
| 6692 if (namedTypesT.length < namedTypesS.length) { | 6849 if (namedTypesT.length < namedTypesS.length) { |
| 6693 return false; | 6850 return false; |
| 6694 } | 6851 } |
| 6695 JavaIterator<MapEntry<String, Type2>> iteratorS = new JavaIterator(getMapE
ntrySet(namedTypesS)); | 6852 JavaIterator<MapEntry<String, Type2>> iteratorS = new JavaIterator(getMapE
ntrySet(namedTypesS)); |
| 6696 while (iteratorS.hasNext) { | 6853 while (iteratorS.hasNext) { |
| 6697 MapEntry<String, Type2> entryS = iteratorS.next(); | 6854 MapEntry<String, Type2> entryS = iteratorS.next(); |
| 6698 Type2 typeT = namedTypesT[entryS.getKey()]; | 6855 Type2 typeT = namedTypesT[entryS.getKey()]; |
| 6699 if (typeT == null) { | 6856 if (typeT == null) { |
| 6700 return false; | 6857 return false; |
| 6701 } | 6858 } |
| 6702 if (!typeT.isMoreSpecificThan3(entryS.getValue(), withDynamic)) { | 6859 if (!(typeT as TypeImpl).isMoreSpecificThan3(entryS.getValue(), withDyna
mic, visitedTypePairs)) { |
| 6703 return false; | 6860 return false; |
| 6704 } | 6861 } |
| 6705 } | 6862 } |
| 6706 } else if (s.namedParameterTypes.length > 0) { | 6863 } else if (s.namedParameterTypes.length > 0) { |
| 6707 return false; | 6864 return false; |
| 6708 } else { | 6865 } else { |
| 6709 int tArgLength = tTypes.length + tOpTypes.length; | 6866 int tArgLength = tTypes.length + tOpTypes.length; |
| 6710 int sArgLength = sTypes.length + sOpTypes.length; | 6867 int sArgLength = sTypes.length + sOpTypes.length; |
| 6711 if (tArgLength < sArgLength || sTypes.length < tTypes.length) { | 6868 if (tArgLength < sArgLength || sTypes.length < tTypes.length) { |
| 6712 return false; | 6869 return false; |
| 6713 } | 6870 } |
| 6714 if (tOpTypes.length == 0 && sOpTypes.length == 0) { | 6871 if (tOpTypes.length == 0 && sOpTypes.length == 0) { |
| 6715 for (int i = 0; i < sTypes.length; i++) { | 6872 for (int i = 0; i < sTypes.length; i++) { |
| 6716 if (!tTypes[i].isMoreSpecificThan3(sTypes[i], withDynamic)) { | 6873 if (!(tTypes[i] as TypeImpl).isMoreSpecificThan3(sTypes[i], withDynami
c, visitedTypePairs)) { |
| 6717 return false; | 6874 return false; |
| 6718 } | 6875 } |
| 6719 } | 6876 } |
| 6720 } else { | 6877 } else { |
| 6721 List<Type2> tAllTypes = new List<Type2>(sArgLength); | 6878 List<Type2> tAllTypes = new List<Type2>(sArgLength); |
| 6722 for (int i = 0; i < tTypes.length; i++) { | 6879 for (int i = 0; i < tTypes.length; i++) { |
| 6723 tAllTypes[i] = tTypes[i]; | 6880 tAllTypes[i] = tTypes[i]; |
| 6724 } | 6881 } |
| 6725 for (int i = tTypes.length, j = 0; i < sArgLength; i++, j++) { | 6882 for (int i = tTypes.length, j = 0; i < sArgLength; i++, j++) { |
| 6726 tAllTypes[i] = tOpTypes[j]; | 6883 tAllTypes[i] = tOpTypes[j]; |
| 6727 } | 6884 } |
| 6728 List<Type2> sAllTypes = new List<Type2>(sArgLength); | 6885 List<Type2> sAllTypes = new List<Type2>(sArgLength); |
| 6729 for (int i = 0; i < sTypes.length; i++) { | 6886 for (int i = 0; i < sTypes.length; i++) { |
| 6730 sAllTypes[i] = sTypes[i]; | 6887 sAllTypes[i] = sTypes[i]; |
| 6731 } | 6888 } |
| 6732 for (int i = sTypes.length, j = 0; i < sArgLength; i++, j++) { | 6889 for (int i = sTypes.length, j = 0; i < sArgLength; i++, j++) { |
| 6733 sAllTypes[i] = sOpTypes[j]; | 6890 sAllTypes[i] = sOpTypes[j]; |
| 6734 } | 6891 } |
| 6735 for (int i = 0; i < sAllTypes.length; i++) { | 6892 for (int i = 0; i < sAllTypes.length; i++) { |
| 6736 if (!tAllTypes[i].isMoreSpecificThan3(sAllTypes[i], withDynamic)) { | 6893 if (!(tAllTypes[i] as TypeImpl).isMoreSpecificThan3(sAllTypes[i], with
Dynamic, visitedTypePairs)) { |
| 6737 return false; | 6894 return false; |
| 6738 } | 6895 } |
| 6739 } | 6896 } |
| 6740 } | 6897 } |
| 6741 } | 6898 } |
| 6742 Type2 tRetType = t.returnType; | 6899 Type2 tRetType = t.returnType; |
| 6743 Type2 sRetType = s.returnType; | 6900 Type2 sRetType = s.returnType; |
| 6744 return sRetType.isVoid || tRetType.isMoreSpecificThan3(sRetType, withDynamic
); | 6901 return sRetType.isVoid || (tRetType as TypeImpl).isMoreSpecificThan3(sRetTyp
e, withDynamic, visitedTypePairs); |
| 6745 } | 6902 } |
| 6746 | 6903 |
| 6747 bool isSubtypeOf(Type2 type) { | 6904 bool isAssignableTo(Type2 type) => isSubtypeOf3(type, new Set<TypeImpl_TypePai
r>()); |
| 6748 if (type == null) { | |
| 6749 return false; | |
| 6750 } else if (identical(this, type) || type.isDynamic || type.isDartCoreFunctio
n || type.isObject) { | |
| 6751 return true; | |
| 6752 } else if (type is! FunctionType) { | |
| 6753 return false; | |
| 6754 } else if (this == type) { | |
| 6755 return true; | |
| 6756 } | |
| 6757 FunctionType t = this; | |
| 6758 FunctionType s = type as FunctionType; | |
| 6759 List<Type2> tTypes = t.normalParameterTypes; | |
| 6760 List<Type2> tOpTypes = t.optionalParameterTypes; | |
| 6761 List<Type2> sTypes = s.normalParameterTypes; | |
| 6762 List<Type2> sOpTypes = s.optionalParameterTypes; | |
| 6763 if ((sOpTypes.length > 0 && t.namedParameterTypes.length > 0) || (tOpTypes.l
ength > 0 && s.namedParameterTypes.length > 0)) { | |
| 6764 return false; | |
| 6765 } | |
| 6766 if (t.namedParameterTypes.length > 0) { | |
| 6767 if (t.normalParameterTypes.length != s.normalParameterTypes.length) { | |
| 6768 return false; | |
| 6769 } else if (t.normalParameterTypes.length > 0) { | |
| 6770 for (int i = 0; i < tTypes.length; i++) { | |
| 6771 if (!tTypes[i].isAssignableTo(sTypes[i])) { | |
| 6772 return false; | |
| 6773 } | |
| 6774 } | |
| 6775 } | |
| 6776 Map<String, Type2> namedTypesT = t.namedParameterTypes; | |
| 6777 Map<String, Type2> namedTypesS = s.namedParameterTypes; | |
| 6778 if (namedTypesT.length < namedTypesS.length) { | |
| 6779 return false; | |
| 6780 } | |
| 6781 JavaIterator<MapEntry<String, Type2>> iteratorS = new JavaIterator(getMapE
ntrySet(namedTypesS)); | |
| 6782 while (iteratorS.hasNext) { | |
| 6783 MapEntry<String, Type2> entryS = iteratorS.next(); | |
| 6784 Type2 typeT = namedTypesT[entryS.getKey()]; | |
| 6785 if (typeT == null) { | |
| 6786 return false; | |
| 6787 } | |
| 6788 if (!typeT.isAssignableTo(entryS.getValue())) { | |
| 6789 return false; | |
| 6790 } | |
| 6791 } | |
| 6792 } else if (s.namedParameterTypes.length > 0) { | |
| 6793 return false; | |
| 6794 } else { | |
| 6795 int tArgLength = tTypes.length + tOpTypes.length; | |
| 6796 int sArgLength = sTypes.length + sOpTypes.length; | |
| 6797 if (tArgLength < sArgLength || sTypes.length < tTypes.length) { | |
| 6798 return false; | |
| 6799 } | |
| 6800 if (tOpTypes.length == 0 && sOpTypes.length == 0) { | |
| 6801 for (int i = 0; i < sTypes.length; i++) { | |
| 6802 if (!tTypes[i].isAssignableTo(sTypes[i])) { | |
| 6803 return false; | |
| 6804 } | |
| 6805 } | |
| 6806 } else { | |
| 6807 List<Type2> tAllTypes = new List<Type2>(sArgLength); | |
| 6808 for (int i = 0; i < tTypes.length; i++) { | |
| 6809 tAllTypes[i] = tTypes[i]; | |
| 6810 } | |
| 6811 for (int i = tTypes.length, j = 0; i < sArgLength; i++, j++) { | |
| 6812 tAllTypes[i] = tOpTypes[j]; | |
| 6813 } | |
| 6814 List<Type2> sAllTypes = new List<Type2>(sArgLength); | |
| 6815 for (int i = 0; i < sTypes.length; i++) { | |
| 6816 sAllTypes[i] = sTypes[i]; | |
| 6817 } | |
| 6818 for (int i = sTypes.length, j = 0; i < sArgLength; i++, j++) { | |
| 6819 sAllTypes[i] = sOpTypes[j]; | |
| 6820 } | |
| 6821 for (int i = 0; i < sAllTypes.length; i++) { | |
| 6822 if (!tAllTypes[i].isAssignableTo(sAllTypes[i])) { | |
| 6823 return false; | |
| 6824 } | |
| 6825 } | |
| 6826 } | |
| 6827 } | |
| 6828 Type2 tRetType = t.returnType; | |
| 6829 Type2 sRetType = s.returnType; | |
| 6830 return sRetType.isVoid || tRetType.isAssignableTo(sRetType); | |
| 6831 } | |
| 6832 | 6905 |
| 6833 /** | 6906 /** |
| 6834 * Set the actual types of the type arguments to the given types. | 6907 * Set the actual types of the type arguments to the given types. |
| 6835 * | 6908 * |
| 6836 * @param typeArguments the actual types of the type arguments | 6909 * @param typeArguments the actual types of the type arguments |
| 6837 */ | 6910 */ |
| 6838 void set typeArguments(List<Type2> typeArguments) { | 6911 void set typeArguments(List<Type2> typeArguments) { |
| 6839 this._typeArguments = typeArguments; | 6912 this._typeArguments = typeArguments; |
| 6840 } | 6913 } |
| 6841 | 6914 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6900 } else { | 6973 } else { |
| 6901 needsComma = true; | 6974 needsComma = true; |
| 6902 } | 6975 } |
| 6903 builder.append(entry.getKey()); | 6976 builder.append(entry.getKey()); |
| 6904 builder.append(": "); | 6977 builder.append(": "); |
| 6905 (entry.getValue() as TypeImpl).appendTo(builder); | 6978 (entry.getValue() as TypeImpl).appendTo(builder); |
| 6906 } | 6979 } |
| 6907 builder.append("}"); | 6980 builder.append("}"); |
| 6908 needsComma = true; | 6981 needsComma = true; |
| 6909 } | 6982 } |
| 6910 builder.append(") -> "); | 6983 builder.append(")"); |
| 6984 builder.append(Element.RIGHT_ARROW); |
| 6911 if (returnType == null) { | 6985 if (returnType == null) { |
| 6912 builder.append("null"); | 6986 builder.append("null"); |
| 6913 } else { | 6987 } else { |
| 6914 (returnType as TypeImpl).appendTo(builder); | 6988 (returnType as TypeImpl).appendTo(builder); |
| 6915 } | 6989 } |
| 6916 } | 6990 } |
| 6917 | 6991 |
| 6918 /** | 6992 /** |
| 6919 * @return the base parameter elements of this function element, not `null`. | 6993 * @return the base parameter elements of this function element, not `null`. |
| 6920 */ | 6994 */ |
| 6921 List<ParameterElement> get baseParameters { | 6995 List<ParameterElement> get baseParameters { |
| 6922 Element element = this.element; | 6996 Element element = this.element; |
| 6923 if (element is ExecutableElement) { | 6997 if (element is ExecutableElement) { |
| 6924 return (element as ExecutableElement).parameters; | 6998 return (element as ExecutableElement).parameters; |
| 6925 } else { | 6999 } else { |
| 6926 return (element as FunctionTypeAliasElement).parameters; | 7000 return (element as FunctionTypeAliasElement).parameters; |
| 6927 } | 7001 } |
| 6928 } | 7002 } |
| 6929 | 7003 |
| 7004 bool internalIsSubtypeOf(Type2 type, Set<TypeImpl_TypePair> visitedTypePairs)
{ |
| 7005 if (type == null) { |
| 7006 return false; |
| 7007 } else if (identical(this, type) || type.isDynamic || type.isDartCoreFunctio
n || type.isObject) { |
| 7008 return true; |
| 7009 } else if (type is! FunctionType) { |
| 7010 return false; |
| 7011 } else if (this == type) { |
| 7012 return true; |
| 7013 } |
| 7014 FunctionType t = this; |
| 7015 FunctionType s = type as FunctionType; |
| 7016 List<Type2> tTypes = t.normalParameterTypes; |
| 7017 List<Type2> tOpTypes = t.optionalParameterTypes; |
| 7018 List<Type2> sTypes = s.normalParameterTypes; |
| 7019 List<Type2> sOpTypes = s.optionalParameterTypes; |
| 7020 if ((sOpTypes.length > 0 && t.namedParameterTypes.length > 0) || (tOpTypes.l
ength > 0 && s.namedParameterTypes.length > 0)) { |
| 7021 return false; |
| 7022 } |
| 7023 if (t.namedParameterTypes.length > 0) { |
| 7024 if (t.normalParameterTypes.length != s.normalParameterTypes.length) { |
| 7025 return false; |
| 7026 } else if (t.normalParameterTypes.length > 0) { |
| 7027 for (int i = 0; i < tTypes.length; i++) { |
| 7028 if (!(tTypes[i] as TypeImpl).isAssignableTo2(sTypes[i], visitedTypePai
rs)) { |
| 7029 return false; |
| 7030 } |
| 7031 } |
| 7032 } |
| 7033 Map<String, Type2> namedTypesT = t.namedParameterTypes; |
| 7034 Map<String, Type2> namedTypesS = s.namedParameterTypes; |
| 7035 if (namedTypesT.length < namedTypesS.length) { |
| 7036 return false; |
| 7037 } |
| 7038 JavaIterator<MapEntry<String, Type2>> iteratorS = new JavaIterator(getMapE
ntrySet(namedTypesS)); |
| 7039 while (iteratorS.hasNext) { |
| 7040 MapEntry<String, Type2> entryS = iteratorS.next(); |
| 7041 Type2 typeT = namedTypesT[entryS.getKey()]; |
| 7042 if (typeT == null) { |
| 7043 return false; |
| 7044 } |
| 7045 if (!(typeT as TypeImpl).isAssignableTo2(entryS.getValue(), visitedTypeP
airs)) { |
| 7046 return false; |
| 7047 } |
| 7048 } |
| 7049 } else if (s.namedParameterTypes.length > 0) { |
| 7050 return false; |
| 7051 } else { |
| 7052 int tArgLength = tTypes.length + tOpTypes.length; |
| 7053 int sArgLength = sTypes.length + sOpTypes.length; |
| 7054 if (tArgLength < sArgLength || sTypes.length < tTypes.length) { |
| 7055 return false; |
| 7056 } |
| 7057 if (tOpTypes.length == 0 && sOpTypes.length == 0) { |
| 7058 for (int i = 0; i < sTypes.length; i++) { |
| 7059 if (!(tTypes[i] as TypeImpl).isAssignableTo2(sTypes[i], visitedTypePai
rs)) { |
| 7060 return false; |
| 7061 } |
| 7062 } |
| 7063 } else { |
| 7064 List<Type2> tAllTypes = new List<Type2>(sArgLength); |
| 7065 for (int i = 0; i < tTypes.length; i++) { |
| 7066 tAllTypes[i] = tTypes[i]; |
| 7067 } |
| 7068 for (int i = tTypes.length, j = 0; i < sArgLength; i++, j++) { |
| 7069 tAllTypes[i] = tOpTypes[j]; |
| 7070 } |
| 7071 List<Type2> sAllTypes = new List<Type2>(sArgLength); |
| 7072 for (int i = 0; i < sTypes.length; i++) { |
| 7073 sAllTypes[i] = sTypes[i]; |
| 7074 } |
| 7075 for (int i = sTypes.length, j = 0; i < sArgLength; i++, j++) { |
| 7076 sAllTypes[i] = sOpTypes[j]; |
| 7077 } |
| 7078 for (int i = 0; i < sAllTypes.length; i++) { |
| 7079 if (!(tAllTypes[i] as TypeImpl).isAssignableTo2(sAllTypes[i], visitedT
ypePairs)) { |
| 7080 return false; |
| 7081 } |
| 7082 } |
| 7083 } |
| 7084 } |
| 7085 Type2 tRetType = t.returnType; |
| 7086 Type2 sRetType = s.returnType; |
| 7087 return sRetType.isVoid || (tRetType as TypeImpl).isAssignableTo2(sRetType, v
isitedTypePairs); |
| 7088 } |
| 7089 |
| 6930 /** | 7090 /** |
| 6931 * Return the return type defined by this function's element. | 7091 * Return the return type defined by this function's element. |
| 6932 * | 7092 * |
| 6933 * @return the return type defined by this function's element | 7093 * @return the return type defined by this function's element |
| 6934 */ | 7094 */ |
| 6935 Type2 get baseReturnType { | 7095 Type2 get baseReturnType { |
| 6936 Element element = this.element; | 7096 Element element = this.element; |
| 6937 if (element is ExecutableElement) { | 7097 if (element is ExecutableElement) { |
| 6938 return (element as ExecutableElement).returnType; | 7098 return (element as ExecutableElement).returnType; |
| 6939 } else { | 7099 } else { |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6987 * @see #computeLongestInheritancePathToObject(Type) | 7147 * @see #computeLongestInheritancePathToObject(Type) |
| 6988 * @see #getLeastUpperBound(Type) | 7148 * @see #getLeastUpperBound(Type) |
| 6989 */ | 7149 */ |
| 6990 static int computeLongestInheritancePathToObject2(InterfaceType type, int dept
h, Set<ClassElement> visitedClasses) { | 7150 static int computeLongestInheritancePathToObject2(InterfaceType type, int dept
h, Set<ClassElement> visitedClasses) { |
| 6991 ClassElement classElement = type.element; | 7151 ClassElement classElement = type.element; |
| 6992 if (classElement.supertype == null || visitedClasses.contains(classElement))
{ | 7152 if (classElement.supertype == null || visitedClasses.contains(classElement))
{ |
| 6993 return depth; | 7153 return depth; |
| 6994 } | 7154 } |
| 6995 int longestPath = 1; | 7155 int longestPath = 1; |
| 6996 try { | 7156 try { |
| 6997 javaSetAdd(visitedClasses, classElement); | 7157 visitedClasses.add(classElement); |
| 6998 List<InterfaceType> superinterfaces = classElement.interfaces; | 7158 List<InterfaceType> superinterfaces = classElement.interfaces; |
| 6999 int pathLength; | 7159 int pathLength; |
| 7000 if (superinterfaces.length > 0) { | 7160 if (superinterfaces.length > 0) { |
| 7001 for (InterfaceType superinterface in superinterfaces) { | 7161 for (InterfaceType superinterface in superinterfaces) { |
| 7002 pathLength = computeLongestInheritancePathToObject2(superinterface, de
pth + 1, visitedClasses); | 7162 pathLength = computeLongestInheritancePathToObject2(superinterface, de
pth + 1, visitedClasses); |
| 7003 if (pathLength > longestPath) { | 7163 if (pathLength > longestPath) { |
| 7004 longestPath = pathLength; | 7164 longestPath = pathLength; |
| 7005 } | 7165 } |
| 7006 } | 7166 } |
| 7007 } | 7167 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 7025 * @return the [Set] of superinterfaces of the passed [Type] | 7185 * @return the [Set] of superinterfaces of the passed [Type] |
| 7026 * @see #computeSuperinterfaceSet(Type) | 7186 * @see #computeSuperinterfaceSet(Type) |
| 7027 * @see #getLeastUpperBound(Type) | 7187 * @see #getLeastUpperBound(Type) |
| 7028 */ | 7188 */ |
| 7029 static Set<InterfaceType> computeSuperinterfaceSet2(InterfaceType type, Set<In
terfaceType> set) { | 7189 static Set<InterfaceType> computeSuperinterfaceSet2(InterfaceType type, Set<In
terfaceType> set) { |
| 7030 Element element = type.element; | 7190 Element element = type.element; |
| 7031 if (element != null && element is ClassElement) { | 7191 if (element != null && element is ClassElement) { |
| 7032 ClassElement classElement = element as ClassElement; | 7192 ClassElement classElement = element as ClassElement; |
| 7033 List<InterfaceType> superinterfaces = classElement.interfaces; | 7193 List<InterfaceType> superinterfaces = classElement.interfaces; |
| 7034 for (InterfaceType superinterface in superinterfaces) { | 7194 for (InterfaceType superinterface in superinterfaces) { |
| 7035 if (javaSetAdd(set, superinterface)) { | 7195 if (set.add(superinterface)) { |
| 7036 computeSuperinterfaceSet2(superinterface, set); | 7196 computeSuperinterfaceSet2(superinterface, set); |
| 7037 } | 7197 } |
| 7038 } | 7198 } |
| 7039 InterfaceType supertype = classElement.supertype; | 7199 InterfaceType supertype = classElement.supertype; |
| 7040 if (supertype != null) { | 7200 if (supertype != null) { |
| 7041 if (javaSetAdd(set, supertype)) { | 7201 if (set.add(supertype)) { |
| 7042 computeSuperinterfaceSet2(supertype, set); | 7202 computeSuperinterfaceSet2(supertype, set); |
| 7043 } | 7203 } |
| 7044 } | 7204 } |
| 7045 } | 7205 } |
| 7046 return set; | 7206 return set; |
| 7047 } | 7207 } |
| 7048 | 7208 |
| 7049 /** | 7209 /** |
| 7050 * Return the intersection of the given sets of types, where intersection is b
ased on the equality | 7210 * Return the intersection of the given sets of types, where intersection is b
ased on the equality |
| 7051 * of the elements of the types rather than on the equality of the types thems
elves. In cases | 7211 * of the elements of the types rather than on the equality of the types thems
elves. In cases |
| 7052 * where two non-equal types have equal elements, which only happens when the
class is | 7212 * where two non-equal types have equal elements, which only happens when the
class is |
| 7053 * parameterized, the type that is added to the intersection is the base type
with type arguments | 7213 * parameterized, the type that is added to the intersection is the base type
with type arguments |
| 7054 * that are the least upper bound of the type arguments of the two types. | 7214 * that are the least upper bound of the type arguments of the two types. |
| 7055 * | 7215 * |
| 7056 * @param first the first set of types to be intersected | 7216 * @param first the first set of types to be intersected |
| 7057 * @param second the second set of types to be intersected | 7217 * @param second the second set of types to be intersected |
| 7058 * @return the intersection of the given sets of types | 7218 * @return the intersection of the given sets of types |
| 7059 */ | 7219 */ |
| 7060 static List<InterfaceType> intersection(Set<InterfaceType> first, Set<Interfac
eType> second) { | 7220 static List<InterfaceType> intersection(Set<InterfaceType> first, Set<Interfac
eType> second) { |
| 7061 Map<ClassElement, InterfaceType> firstMap = new Map<ClassElement, InterfaceT
ype>(); | 7221 Map<ClassElement, InterfaceType> firstMap = new Map<ClassElement, InterfaceT
ype>(); |
| 7062 for (InterfaceType firstType in first) { | 7222 for (InterfaceType firstType in first) { |
| 7063 firstMap[firstType.element] = firstType; | 7223 firstMap[firstType.element] = firstType; |
| 7064 } | 7224 } |
| 7065 Set<InterfaceType> result = new Set<InterfaceType>(); | 7225 Set<InterfaceType> result = new Set<InterfaceType>(); |
| 7066 for (InterfaceType secondType in second) { | 7226 for (InterfaceType secondType in second) { |
| 7067 InterfaceType firstType = firstMap[secondType.element]; | 7227 InterfaceType firstType = firstMap[secondType.element]; |
| 7068 if (firstType != null) { | 7228 if (firstType != null) { |
| 7069 javaSetAdd(result, leastUpperBound(firstType, secondType)); | 7229 result.add(leastUpperBound(firstType, secondType)); |
| 7070 } | 7230 } |
| 7071 } | 7231 } |
| 7072 return new List.from(result); | 7232 return new List.from(result); |
| 7073 } | 7233 } |
| 7074 | 7234 |
| 7075 /** | 7235 /** |
| 7076 * Return the "least upper bound" of the given types under the assumption that
the types have the | 7236 * Return the "least upper bound" of the given types under the assumption that
the types have the |
| 7077 * same element and differ only in terms of the type arguments. The resulting
type is composed by | 7237 * same element and differ only in terms of the type arguments. The resulting
type is composed by |
| 7078 * comparing the corresponding type arguments, keeping those that are the same
, and using | 7238 * comparing the corresponding type arguments, keeping those that are the same
, and using |
| 7079 * 'dynamic' for those that are different. | 7239 * 'dynamic' for those that are different. |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7198 if (identical(this, dynamicType) || identical(type, dynamicType)) { | 7358 if (identical(this, dynamicType) || identical(type, dynamicType)) { |
| 7199 return dynamicType; | 7359 return dynamicType; |
| 7200 } | 7360 } |
| 7201 if (type is! InterfaceType) { | 7361 if (type is! InterfaceType) { |
| 7202 return null; | 7362 return null; |
| 7203 } | 7363 } |
| 7204 InterfaceType i = this; | 7364 InterfaceType i = this; |
| 7205 InterfaceType j = type as InterfaceType; | 7365 InterfaceType j = type as InterfaceType; |
| 7206 Set<InterfaceType> si = computeSuperinterfaceSet(i); | 7366 Set<InterfaceType> si = computeSuperinterfaceSet(i); |
| 7207 Set<InterfaceType> sj = computeSuperinterfaceSet(j); | 7367 Set<InterfaceType> sj = computeSuperinterfaceSet(j); |
| 7208 javaSetAdd(si, i); | 7368 si.add(i); |
| 7209 javaSetAdd(sj, j); | 7369 sj.add(j); |
| 7210 List<InterfaceType> s = intersection(si, sj); | 7370 List<InterfaceType> s = intersection(si, sj); |
| 7211 List<int> depths = new List<int>.filled(s.length, 0); | 7371 List<int> depths = new List<int>.filled(s.length, 0); |
| 7212 int maxDepth = 0; | 7372 int maxDepth = 0; |
| 7213 for (int n = 0; n < s.length; n++) { | 7373 for (int n = 0; n < s.length; n++) { |
| 7214 depths[n] = computeLongestInheritancePathToObject(s[n]); | 7374 depths[n] = computeLongestInheritancePathToObject(s[n]); |
| 7215 if (depths[n] > maxDepth) { | 7375 if (depths[n] > maxDepth) { |
| 7216 maxDepth = depths[n]; | 7376 maxDepth = depths[n]; |
| 7217 } | 7377 } |
| 7218 } | 7378 } |
| 7219 for (; maxDepth >= 0; maxDepth--) { | 7379 for (; maxDepth >= 0; maxDepth--) { |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7312 } | 7472 } |
| 7313 for (InterfaceType mixinType in jElement.mixins) { | 7473 for (InterfaceType mixinType in jElement.mixins) { |
| 7314 mixinType = mixinType.substitute2(jArgs, jVars); | 7474 mixinType = mixinType.substitute2(jArgs, jVars); |
| 7315 if (mixinType == i) { | 7475 if (mixinType == i) { |
| 7316 return true; | 7476 return true; |
| 7317 } | 7477 } |
| 7318 } | 7478 } |
| 7319 return false; | 7479 return false; |
| 7320 } | 7480 } |
| 7321 | 7481 |
| 7322 bool isMoreSpecificThan3(Type2 type, bool withDynamic) { | |
| 7323 if (identical(type, DynamicTypeImpl.instance)) { | |
| 7324 return true; | |
| 7325 } else if (type is! InterfaceType) { | |
| 7326 return false; | |
| 7327 } | |
| 7328 return isMoreSpecificThan2(type as InterfaceType, new Set<ClassElement>(), w
ithDynamic); | |
| 7329 } | |
| 7330 | |
| 7331 bool get isObject => element.supertype == null; | 7482 bool get isObject => element.supertype == null; |
| 7332 | 7483 |
| 7333 bool isSubtypeOf(Type2 type) { | |
| 7334 if (identical(type, DynamicTypeImpl.instance)) { | |
| 7335 return true; | |
| 7336 } else if (type is TypeParameterType) { | |
| 7337 return true; | |
| 7338 } else if (type is FunctionType) { | |
| 7339 ClassElement element = this.element; | |
| 7340 MethodElement callMethod = element.lookUpMethod("call", element.library); | |
| 7341 if (callMethod != null) { | |
| 7342 return callMethod.type.isSubtypeOf(type); | |
| 7343 } | |
| 7344 return false; | |
| 7345 } else if (type is! InterfaceType) { | |
| 7346 return false; | |
| 7347 } else if (this == type) { | |
| 7348 return true; | |
| 7349 } | |
| 7350 return isSubtypeOf2(type as InterfaceType, new Set<ClassElement>()); | |
| 7351 } | |
| 7352 | |
| 7353 ConstructorElement lookUpConstructor(String constructorName, LibraryElement li
brary) { | 7484 ConstructorElement lookUpConstructor(String constructorName, LibraryElement li
brary) { |
| 7354 ConstructorElement constructorElement; | 7485 ConstructorElement constructorElement; |
| 7355 if (constructorName == null) { | 7486 if (constructorName == null) { |
| 7356 constructorElement = element.unnamedConstructor; | 7487 constructorElement = element.unnamedConstructor; |
| 7357 } else { | 7488 } else { |
| 7358 constructorElement = element.getNamedConstructor(constructorName); | 7489 constructorElement = element.getNamedConstructor(constructorName); |
| 7359 } | 7490 } |
| 7360 if (constructorElement == null || !constructorElement.isAccessibleIn(library
)) { | 7491 if (constructorElement == null || !constructorElement.isAccessibleIn(library
)) { |
| 7361 return null; | 7492 return null; |
| 7362 } | 7493 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 7375 for (InterfaceType mixin in mixins) { | 7506 for (InterfaceType mixin in mixins) { |
| 7376 PropertyAccessorElement element = mixin.getGetter(getterName); | 7507 PropertyAccessorElement element = mixin.getGetter(getterName); |
| 7377 if (element != null && element.isAccessibleIn(library)) { | 7508 if (element != null && element.isAccessibleIn(library)) { |
| 7378 return element; | 7509 return element; |
| 7379 } | 7510 } |
| 7380 } | 7511 } |
| 7381 Set<ClassElement> visitedClasses = new Set<ClassElement>(); | 7512 Set<ClassElement> visitedClasses = new Set<ClassElement>(); |
| 7382 InterfaceType supertype = superclass; | 7513 InterfaceType supertype = superclass; |
| 7383 ClassElement supertypeElement = supertype == null ? null : supertype.element
; | 7514 ClassElement supertypeElement = supertype == null ? null : supertype.element
; |
| 7384 while (supertype != null && !visitedClasses.contains(supertypeElement)) { | 7515 while (supertype != null && !visitedClasses.contains(supertypeElement)) { |
| 7385 javaSetAdd(visitedClasses, supertypeElement); | 7516 visitedClasses.add(supertypeElement); |
| 7386 PropertyAccessorElement element = supertype.getGetter(getterName); | 7517 PropertyAccessorElement element = supertype.getGetter(getterName); |
| 7387 if (element != null && element.isAccessibleIn(library)) { | 7518 if (element != null && element.isAccessibleIn(library)) { |
| 7388 return element; | 7519 return element; |
| 7389 } | 7520 } |
| 7390 for (InterfaceType mixin in supertype.mixins) { | 7521 for (InterfaceType mixin in supertype.mixins) { |
| 7391 element = mixin.getGetter(getterName); | 7522 element = mixin.getGetter(getterName); |
| 7392 if (element != null && element.isAccessibleIn(library)) { | 7523 if (element != null && element.isAccessibleIn(library)) { |
| 7393 return element; | 7524 return element; |
| 7394 } | 7525 } |
| 7395 } | 7526 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 7411 for (InterfaceType mixin in mixins) { | 7542 for (InterfaceType mixin in mixins) { |
| 7412 MethodElement element = mixin.getMethod(methodName); | 7543 MethodElement element = mixin.getMethod(methodName); |
| 7413 if (element != null && element.isAccessibleIn(library)) { | 7544 if (element != null && element.isAccessibleIn(library)) { |
| 7414 return element; | 7545 return element; |
| 7415 } | 7546 } |
| 7416 } | 7547 } |
| 7417 Set<ClassElement> visitedClasses = new Set<ClassElement>(); | 7548 Set<ClassElement> visitedClasses = new Set<ClassElement>(); |
| 7418 InterfaceType supertype = superclass; | 7549 InterfaceType supertype = superclass; |
| 7419 ClassElement supertypeElement = supertype == null ? null : supertype.element
; | 7550 ClassElement supertypeElement = supertype == null ? null : supertype.element
; |
| 7420 while (supertype != null && !visitedClasses.contains(supertypeElement)) { | 7551 while (supertype != null && !visitedClasses.contains(supertypeElement)) { |
| 7421 javaSetAdd(visitedClasses, supertypeElement); | 7552 visitedClasses.add(supertypeElement); |
| 7422 MethodElement element = supertype.getMethod(methodName); | 7553 MethodElement element = supertype.getMethod(methodName); |
| 7423 if (element != null && element.isAccessibleIn(library)) { | 7554 if (element != null && element.isAccessibleIn(library)) { |
| 7424 return element; | 7555 return element; |
| 7425 } | 7556 } |
| 7426 for (InterfaceType mixin in supertype.mixins) { | 7557 for (InterfaceType mixin in supertype.mixins) { |
| 7427 element = mixin.getMethod(methodName); | 7558 element = mixin.getMethod(methodName); |
| 7428 if (element != null && element.isAccessibleIn(library)) { | 7559 if (element != null && element.isAccessibleIn(library)) { |
| 7429 return element; | 7560 return element; |
| 7430 } | 7561 } |
| 7431 } | 7562 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 7447 for (InterfaceType mixin in mixins) { | 7578 for (InterfaceType mixin in mixins) { |
| 7448 PropertyAccessorElement element = mixin.getSetter(setterName); | 7579 PropertyAccessorElement element = mixin.getSetter(setterName); |
| 7449 if (element != null && element.isAccessibleIn(library)) { | 7580 if (element != null && element.isAccessibleIn(library)) { |
| 7450 return element; | 7581 return element; |
| 7451 } | 7582 } |
| 7452 } | 7583 } |
| 7453 Set<ClassElement> visitedClasses = new Set<ClassElement>(); | 7584 Set<ClassElement> visitedClasses = new Set<ClassElement>(); |
| 7454 InterfaceType supertype = superclass; | 7585 InterfaceType supertype = superclass; |
| 7455 ClassElement supertypeElement = supertype == null ? null : supertype.element
; | 7586 ClassElement supertypeElement = supertype == null ? null : supertype.element
; |
| 7456 while (supertype != null && !visitedClasses.contains(supertypeElement)) { | 7587 while (supertype != null && !visitedClasses.contains(supertypeElement)) { |
| 7457 javaSetAdd(visitedClasses, supertypeElement); | 7588 visitedClasses.add(supertypeElement); |
| 7458 PropertyAccessorElement element = supertype.getSetter(setterName); | 7589 PropertyAccessorElement element = supertype.getSetter(setterName); |
| 7459 if (element != null && element.isAccessibleIn(library)) { | 7590 if (element != null && element.isAccessibleIn(library)) { |
| 7460 return element; | 7591 return element; |
| 7461 } | 7592 } |
| 7462 for (InterfaceType mixin in supertype.mixins) { | 7593 for (InterfaceType mixin in supertype.mixins) { |
| 7463 element = mixin.getSetter(setterName); | 7594 element = mixin.getSetter(setterName); |
| 7464 if (element != null && element.isAccessibleIn(library)) { | 7595 if (element != null && element.isAccessibleIn(library)) { |
| 7465 return element; | 7596 return element; |
| 7466 } | 7597 } |
| 7467 } | 7598 } |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7506 for (int i = 0; i < argumentCount; i++) { | 7637 for (int i = 0; i < argumentCount; i++) { |
| 7507 if (i > 0) { | 7638 if (i > 0) { |
| 7508 builder.append(", "); | 7639 builder.append(", "); |
| 7509 } | 7640 } |
| 7510 (_typeArguments[i] as TypeImpl).appendTo(builder); | 7641 (_typeArguments[i] as TypeImpl).appendTo(builder); |
| 7511 } | 7642 } |
| 7512 builder.append(">"); | 7643 builder.append(">"); |
| 7513 } | 7644 } |
| 7514 } | 7645 } |
| 7515 | 7646 |
| 7516 bool isMoreSpecificThan2(InterfaceType s, Set<ClassElement> visitedClasses, bo
ol withDynamic) { | 7647 bool internalIsMoreSpecificThan(Type2 type, bool withDynamic, Set<TypeImpl_Typ
ePair> visitedTypePairs) { |
| 7648 if (identical(type, DynamicTypeImpl.instance)) { |
| 7649 return true; |
| 7650 } else if (type is! InterfaceType) { |
| 7651 return false; |
| 7652 } |
| 7653 return isMoreSpecificThan2(type as InterfaceType, new Set<ClassElement>(), w
ithDynamic, visitedTypePairs); |
| 7654 } |
| 7655 |
| 7656 bool internalIsSubtypeOf(Type2 type, Set<TypeImpl_TypePair> visitedTypePairs)
{ |
| 7657 if (identical(type, DynamicTypeImpl.instance)) { |
| 7658 return true; |
| 7659 } else if (type is TypeParameterType) { |
| 7660 return true; |
| 7661 } else if (type is FunctionType) { |
| 7662 ClassElement element = this.element; |
| 7663 MethodElement callMethod = element.lookUpMethod("call", element.library); |
| 7664 if (callMethod != null) { |
| 7665 return callMethod.type.isSubtypeOf(type); |
| 7666 } |
| 7667 return false; |
| 7668 } else if (type is! InterfaceType) { |
| 7669 return false; |
| 7670 } else if (this == type) { |
| 7671 return true; |
| 7672 } |
| 7673 return isSubtypeOf2(type as InterfaceType, new Set<ClassElement>(), visitedT
ypePairs); |
| 7674 } |
| 7675 |
| 7676 bool isMoreSpecificThan2(InterfaceType s, Set<ClassElement> visitedClasses, bo
ol withDynamic, Set<TypeImpl_TypePair> visitedTypePairs) { |
| 7517 if (this == s) { | 7677 if (this == s) { |
| 7518 return true; | 7678 return true; |
| 7519 } | 7679 } |
| 7520 if (s.isDirectSupertypeOf(this)) { | 7680 if (s.isDirectSupertypeOf(this)) { |
| 7521 return true; | 7681 return true; |
| 7522 } | 7682 } |
| 7523 ClassElement tElement = this.element; | 7683 ClassElement tElement = this.element; |
| 7524 ClassElement sElement = s.element; | 7684 ClassElement sElement = s.element; |
| 7525 if (tElement == sElement) { | 7685 if (tElement == sElement) { |
| 7526 List<Type2> tArguments = typeArguments; | 7686 List<Type2> tArguments = typeArguments; |
| 7527 List<Type2> sArguments = s.typeArguments; | 7687 List<Type2> sArguments = s.typeArguments; |
| 7528 if (tArguments.length != sArguments.length) { | 7688 if (tArguments.length != sArguments.length) { |
| 7529 return false; | 7689 return false; |
| 7530 } | 7690 } |
| 7531 for (int i = 0; i < tArguments.length; i++) { | 7691 for (int i = 0; i < tArguments.length; i++) { |
| 7532 if (!tArguments[i].isMoreSpecificThan3(sArguments[i], withDynamic)) { | 7692 if (!(tArguments[i] as TypeImpl).isMoreSpecificThan3(sArguments[i], with
Dynamic, visitedTypePairs)) { |
| 7533 return false; | 7693 return false; |
| 7534 } | 7694 } |
| 7535 } | 7695 } |
| 7536 return true; | 7696 return true; |
| 7537 } | 7697 } |
| 7538 ClassElement element = this.element; | 7698 ClassElement element = this.element; |
| 7539 if (element == null || visitedClasses.contains(element)) { | 7699 if (element == null || visitedClasses.contains(element)) { |
| 7540 return false; | 7700 return false; |
| 7541 } | 7701 } |
| 7542 javaSetAdd(visitedClasses, element); | 7702 visitedClasses.add(element); |
| 7543 InterfaceType supertype = superclass; | 7703 InterfaceType supertype = superclass; |
| 7544 if (supertype != null && (supertype as InterfaceTypeImpl).isMoreSpecificThan
2(s, visitedClasses, withDynamic)) { | 7704 if (supertype != null && (supertype as InterfaceTypeImpl).isMoreSpecificThan
2(s, visitedClasses, withDynamic, visitedTypePairs)) { |
| 7545 return true; | 7705 return true; |
| 7546 } | 7706 } |
| 7547 for (InterfaceType interfaceType in interfaces) { | 7707 for (InterfaceType interfaceType in interfaces) { |
| 7548 if ((interfaceType as InterfaceTypeImpl).isMoreSpecificThan2(s, visitedCla
sses, withDynamic)) { | 7708 if ((interfaceType as InterfaceTypeImpl).isMoreSpecificThan2(s, visitedCla
sses, withDynamic, visitedTypePairs)) { |
| 7549 return true; | 7709 return true; |
| 7550 } | 7710 } |
| 7551 } | 7711 } |
| 7552 for (InterfaceType mixinType in mixins) { | 7712 for (InterfaceType mixinType in mixins) { |
| 7553 if ((mixinType as InterfaceTypeImpl).isMoreSpecificThan2(s, visitedClasses
, withDynamic)) { | 7713 if ((mixinType as InterfaceTypeImpl).isMoreSpecificThan2(s, visitedClasses
, withDynamic, visitedTypePairs)) { |
| 7554 return true; | 7714 return true; |
| 7555 } | 7715 } |
| 7556 } | 7716 } |
| 7557 return false; | 7717 return false; |
| 7558 } | 7718 } |
| 7559 | 7719 |
| 7560 bool isSubtypeOf2(InterfaceType type, Set<ClassElement> visitedClasses) { | 7720 bool isSubtypeOf2(InterfaceType type, Set<ClassElement> visitedClasses, Set<Ty
peImpl_TypePair> visitedTypePairs) { |
| 7561 InterfaceType typeT = this; | 7721 InterfaceType typeT = this; |
| 7562 InterfaceType typeS = type; | 7722 InterfaceType typeS = type; |
| 7563 ClassElement elementT = element; | 7723 ClassElement elementT = element; |
| 7564 if (elementT == null || visitedClasses.contains(elementT)) { | 7724 if (elementT == null || visitedClasses.contains(elementT)) { |
| 7565 return false; | 7725 return false; |
| 7566 } | 7726 } |
| 7567 javaSetAdd(visitedClasses, elementT); | 7727 visitedClasses.add(elementT); |
| 7568 if (typeT == typeS) { | 7728 if (typeT == typeS) { |
| 7569 return true; | 7729 return true; |
| 7570 } else if (elementT == typeS.element) { | 7730 } else if (elementT == typeS.element) { |
| 7571 List<Type2> typeTArgs = typeT.typeArguments; | 7731 List<Type2> typeTArgs = typeT.typeArguments; |
| 7572 List<Type2> typeSArgs = typeS.typeArguments; | 7732 List<Type2> typeSArgs = typeS.typeArguments; |
| 7573 if (typeTArgs.length != typeSArgs.length) { | 7733 if (typeTArgs.length != typeSArgs.length) { |
| 7574 return false; | 7734 return false; |
| 7575 } | 7735 } |
| 7576 for (int i = 0; i < typeTArgs.length; i++) { | 7736 for (int i = 0; i < typeTArgs.length; i++) { |
| 7577 if (!typeTArgs[i].isSubtypeOf(typeSArgs[i])) { | 7737 if (!(typeTArgs[i] as TypeImpl).isSubtypeOf3(typeSArgs[i], visitedTypePa
irs)) { |
| 7578 return false; | 7738 return false; |
| 7579 } | 7739 } |
| 7580 } | 7740 } |
| 7581 return true; | 7741 return true; |
| 7582 } else if (typeS.isDartCoreFunction && elementT.getMethod("call") != null) { | 7742 } else if (typeS.isDartCoreFunction && elementT.getMethod("call") != null) { |
| 7583 return true; | 7743 return true; |
| 7584 } | 7744 } |
| 7585 InterfaceType supertype = superclass; | 7745 InterfaceType supertype = superclass; |
| 7586 if (supertype != null && (supertype as InterfaceTypeImpl).isSubtypeOf2(typeS
, visitedClasses)) { | 7746 if (supertype != null && (supertype as InterfaceTypeImpl).isSubtypeOf2(typeS
, visitedClasses, visitedTypePairs)) { |
| 7587 return true; | 7747 return true; |
| 7588 } | 7748 } |
| 7589 List<InterfaceType> interfaceTypes = interfaces; | 7749 List<InterfaceType> interfaceTypes = interfaces; |
| 7590 for (InterfaceType interfaceType in interfaceTypes) { | 7750 for (InterfaceType interfaceType in interfaceTypes) { |
| 7591 if ((interfaceType as InterfaceTypeImpl).isSubtypeOf2(typeS, visitedClasse
s)) { | 7751 if ((interfaceType as InterfaceTypeImpl).isSubtypeOf2(typeS, visitedClasse
s, visitedTypePairs)) { |
| 7592 return true; | 7752 return true; |
| 7593 } | 7753 } |
| 7594 } | 7754 } |
| 7595 List<InterfaceType> mixinTypes = mixins; | 7755 List<InterfaceType> mixinTypes = mixins; |
| 7596 for (InterfaceType mixinType in mixinTypes) { | 7756 for (InterfaceType mixinType in mixinTypes) { |
| 7597 if ((mixinType as InterfaceTypeImpl).isSubtypeOf2(typeS, visitedClasses))
{ | 7757 if ((mixinType as InterfaceTypeImpl).isSubtypeOf2(typeS, visitedClasses, v
isitedTypePairs)) { |
| 7598 return true; | 7758 return true; |
| 7599 } | 7759 } |
| 7600 } | 7760 } |
| 7601 return false; | 7761 return false; |
| 7602 } | 7762 } |
| 7603 } | 7763 } |
| 7604 | 7764 |
| 7605 /** | 7765 /** |
| 7606 * The abstract class `TypeImpl` implements the behavior common to objects repre
senting the | 7766 * The abstract class `TypeImpl` implements the behavior common to objects repre
senting the |
| 7607 * declared type of elements in the element model. | 7767 * declared type of elements in the element model. |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7658 } | 7818 } |
| 7659 | 7819 |
| 7660 String get displayName => name; | 7820 String get displayName => name; |
| 7661 | 7821 |
| 7662 Element get element => _element; | 7822 Element get element => _element; |
| 7663 | 7823 |
| 7664 Type2 getLeastUpperBound(Type2 type) => null; | 7824 Type2 getLeastUpperBound(Type2 type) => null; |
| 7665 | 7825 |
| 7666 String get name => _name; | 7826 String get name => _name; |
| 7667 | 7827 |
| 7668 bool isAssignableTo(Type2 type) => this.isSubtypeOf(type) || type.isSubtypeOf(
this); | 7828 bool isAssignableTo(Type2 type) => isAssignableTo2(type, new Set<TypeImpl_Type
Pair>()); |
| 7829 |
| 7830 /** |
| 7831 * Return `true` if this type is assignable to the given type. A type <i>T</i>
may be |
| 7832 * assigned to a type <i>S</i>, written <i>T</i> ⇔ <i>S</i>, iff either <
i>T</i> <: <i>S</i> |
| 7833 * or <i>S</i> <: <i>T</i>. |
| 7834 * |
| 7835 * The given set of pairs of types (T1, T2), where each pair indicates that we
invoked this method |
| 7836 * because we are in the process of answering the question of whether T1 is a
subtype of T2, is |
| 7837 * used to prevent infinite loops. |
| 7838 * |
| 7839 * @param type the type being compared with this type |
| 7840 * @param visitedPairs the set of pairs of types used to prevent infinite loop
s |
| 7841 * @return `true` if this type is assignable to the given type |
| 7842 */ |
| 7843 bool isAssignableTo2(Type2 type, Set<TypeImpl_TypePair> visitedTypePairs) => i
sSubtypeOf3(type, visitedTypePairs) || (type as TypeImpl).isSubtypeOf3(this, vis
itedTypePairs); |
| 7669 | 7844 |
| 7670 bool get isBottom => false; | 7845 bool get isBottom => false; |
| 7671 | 7846 |
| 7672 bool get isDartCoreFunction => false; | 7847 bool get isDartCoreFunction => false; |
| 7673 | 7848 |
| 7674 bool get isDynamic => false; | 7849 bool get isDynamic => false; |
| 7675 | 7850 |
| 7676 bool isMoreSpecificThan(Type2 type) => isMoreSpecificThan3(type, false); | 7851 bool isMoreSpecificThan(Type2 type) => isMoreSpecificThan3(type, false, new Se
t<TypeImpl_TypePair>()); |
| 7677 | 7852 |
| 7678 bool isMoreSpecificThan3(Type2 type, bool withDynamic) => false; | 7853 /** |
| 7854 * Return `true` if this type is more specific than the given type. |
| 7855 * |
| 7856 * The given set of pairs of types (T1, T2), where each pair indicates that we
invoked this method |
| 7857 * because we are in the process of answering the question of whether T1 is a
subtype of T2, is |
| 7858 * used to prevent infinite loops. |
| 7859 * |
| 7860 * @param type the type being compared with this type |
| 7861 * @param withDynamic `true` if "dynamic" should be considered as a subtype of
any type |
| 7862 * @param visitedPairs the set of pairs of types used to prevent infinite loop
s |
| 7863 * @return `true` if this type is more specific than the given type |
| 7864 */ |
| 7865 bool isMoreSpecificThan3(Type2 type, bool withDynamic, Set<TypeImpl_TypePair>
visitedTypePairs) { |
| 7866 TypeImpl_TypePair typePair = new TypeImpl_TypePair(this, type); |
| 7867 if (!visitedTypePairs.add(typePair)) { |
| 7868 return false; |
| 7869 } |
| 7870 bool result = internalIsMoreSpecificThan(type, withDynamic, visitedTypePairs
); |
| 7871 visitedTypePairs.remove(typePair); |
| 7872 return result; |
| 7873 } |
| 7679 | 7874 |
| 7680 bool get isObject => false; | 7875 bool get isObject => false; |
| 7681 | 7876 |
| 7877 bool isSubtypeOf(Type2 type) => isSubtypeOf3(type, new Set<TypeImpl_TypePair>(
)); |
| 7878 |
| 7879 /** |
| 7880 * Return `true` if this type is a subtype of the given type. |
| 7881 * |
| 7882 * The given set of pairs of types (T1, T2), where each pair indicates that we
invoked this method |
| 7883 * because we are in the process of answering the question of whether T1 is a
subtype of T2, is |
| 7884 * used to prevent infinite loops. |
| 7885 * |
| 7886 * @param type the type being compared with this type |
| 7887 * @param visitedPairs the set of pairs of types used to prevent infinite loop
s |
| 7888 * @return `true` if this type is a subtype of the given type |
| 7889 */ |
| 7890 bool isSubtypeOf3(Type2 type, Set<TypeImpl_TypePair> visitedTypePairs) { |
| 7891 TypeImpl_TypePair typePair = new TypeImpl_TypePair(this, type); |
| 7892 if (!visitedTypePairs.add(typePair)) { |
| 7893 return false; |
| 7894 } |
| 7895 bool result = internalIsSubtypeOf(type, visitedTypePairs); |
| 7896 visitedTypePairs.remove(typePair); |
| 7897 return result; |
| 7898 } |
| 7899 |
| 7682 bool isSupertypeOf(Type2 type) => type.isSubtypeOf(this); | 7900 bool isSupertypeOf(Type2 type) => type.isSubtypeOf(this); |
| 7683 | 7901 |
| 7684 bool get isVoid => false; | 7902 bool get isVoid => false; |
| 7685 | 7903 |
| 7686 String toString() { | 7904 String toString() { |
| 7687 JavaStringBuilder builder = new JavaStringBuilder(); | 7905 JavaStringBuilder builder = new JavaStringBuilder(); |
| 7688 appendTo(builder); | 7906 appendTo(builder); |
| 7689 return builder.toString(); | 7907 return builder.toString(); |
| 7690 } | 7908 } |
| 7691 | 7909 |
| 7692 /** | 7910 /** |
| 7693 * Append a textual representation of this type to the given builder. | 7911 * Append a textual representation of this type to the given builder. |
| 7694 * | 7912 * |
| 7695 * @param builder the builder to which the text is to be appended | 7913 * @param builder the builder to which the text is to be appended |
| 7696 */ | 7914 */ |
| 7697 void appendTo(JavaStringBuilder builder) { | 7915 void appendTo(JavaStringBuilder builder) { |
| 7698 if (_name == null) { | 7916 if (_name == null) { |
| 7699 builder.append("<unnamed type>"); | 7917 builder.append("<unnamed type>"); |
| 7700 } else { | 7918 } else { |
| 7701 builder.append(_name); | 7919 builder.append(_name); |
| 7702 } | 7920 } |
| 7703 } | 7921 } |
| 7922 |
| 7923 bool internalIsMoreSpecificThan(Type2 type, bool withDynamic, Set<TypeImpl_Typ
ePair> visitedTypePairs); |
| 7924 |
| 7925 bool internalIsSubtypeOf(Type2 type, Set<TypeImpl_TypePair> visitedTypePairs); |
| 7926 } |
| 7927 |
| 7928 class TypeImpl_TypePair { |
| 7929 Type2 _firstType; |
| 7930 |
| 7931 Type2 _secondType; |
| 7932 |
| 7933 TypeImpl_TypePair(Type2 firstType, Type2 secondType) { |
| 7934 this._firstType = firstType; |
| 7935 this._secondType = secondType; |
| 7936 } |
| 7937 |
| 7938 bool operator ==(Object object) { |
| 7939 if (identical(object, this)) { |
| 7940 return true; |
| 7941 } |
| 7942 if (object is TypeImpl_TypePair) { |
| 7943 TypeImpl_TypePair typePair = object as TypeImpl_TypePair; |
| 7944 return _firstType == typePair._firstType && _secondType != null && _second
Type == typePair._secondType; |
| 7945 } |
| 7946 return false; |
| 7947 } |
| 7948 |
| 7949 int get hashCode { |
| 7950 int firstHashCode = 0; |
| 7951 if (_firstType != null) { |
| 7952 firstHashCode = _firstType.element == null ? 0 : _firstType.element.hashCo
de; |
| 7953 } |
| 7954 int secondHashCode = 0; |
| 7955 if (_secondType != null) { |
| 7956 secondHashCode = _secondType.element == null ? 0 : _secondType.element.has
hCode; |
| 7957 } |
| 7958 return firstHashCode + secondHashCode; |
| 7959 } |
| 7704 } | 7960 } |
| 7705 | 7961 |
| 7706 /** | 7962 /** |
| 7707 * Instances of the class `TypeParameterTypeImpl` defines the behavior of object
s representing | 7963 * Instances of the class `TypeParameterTypeImpl` defines the behavior of object
s representing |
| 7708 * the type introduced by a type parameter. | 7964 * the type introduced by a type parameter. |
| 7709 * | 7965 * |
| 7710 * @coverage dart.engine.type | 7966 * @coverage dart.engine.type |
| 7711 */ | 7967 */ |
| 7712 class TypeParameterTypeImpl extends TypeImpl implements TypeParameterType { | 7968 class TypeParameterTypeImpl extends TypeImpl implements TypeParameterType { |
| 7713 /** | 7969 /** |
| (...skipping 28 matching lines...) Expand all Loading... |
| 7742 * @param element the element representing the declaration of the type paramet
er | 7998 * @param element the element representing the declaration of the type paramet
er |
| 7743 */ | 7999 */ |
| 7744 TypeParameterTypeImpl(TypeParameterElement element) : super(element, element.n
ame); | 8000 TypeParameterTypeImpl(TypeParameterElement element) : super(element, element.n
ame); |
| 7745 | 8001 |
| 7746 bool operator ==(Object object) => object is TypeParameterTypeImpl && (element
== (object as TypeParameterTypeImpl).element); | 8002 bool operator ==(Object object) => object is TypeParameterTypeImpl && (element
== (object as TypeParameterTypeImpl).element); |
| 7747 | 8003 |
| 7748 TypeParameterElement get element => super.element as TypeParameterElement; | 8004 TypeParameterElement get element => super.element as TypeParameterElement; |
| 7749 | 8005 |
| 7750 int get hashCode => element.hashCode; | 8006 int get hashCode => element.hashCode; |
| 7751 | 8007 |
| 7752 bool isMoreSpecificThan3(Type2 s, bool withDynamic) { | 8008 Type2 substitute2(List<Type2> argumentTypes, List<Type2> parameterTypes) { |
| 8009 int length = parameterTypes.length; |
| 8010 for (int i = 0; i < length; i++) { |
| 8011 if (parameterTypes[i] == this) { |
| 8012 return argumentTypes[i]; |
| 8013 } |
| 8014 } |
| 8015 return this; |
| 8016 } |
| 8017 |
| 8018 bool internalIsMoreSpecificThan(Type2 s, bool withDynamic, Set<TypeImpl_TypePa
ir> visitedTypePairs) { |
| 7753 if (this == s) { | 8019 if (this == s) { |
| 7754 return true; | 8020 return true; |
| 7755 } | 8021 } |
| 7756 if (s.isBottom) { | 8022 if (s.isBottom) { |
| 7757 return true; | 8023 return true; |
| 7758 } | 8024 } |
| 7759 if (s.isDynamic) { | 8025 if (s.isDynamic) { |
| 7760 return true; | 8026 return true; |
| 7761 } | 8027 } |
| 7762 return isMoreSpecificThan4(s, new Set<Type2>(), withDynamic); | 8028 return isMoreSpecificThan4(s, new Set<Type2>(), withDynamic, visitedTypePair
s); |
| 7763 } | 8029 } |
| 7764 | 8030 |
| 7765 bool isSubtypeOf(Type2 s) => isMoreSpecificThan3(s, true); | 8031 bool internalIsSubtypeOf(Type2 type, Set<TypeImpl_TypePair> visitedTypePairs)
=> isMoreSpecificThan3(type, true, new Set<TypeImpl_TypePair>()); |
| 7766 | 8032 |
| 7767 Type2 substitute2(List<Type2> argumentTypes, List<Type2> parameterTypes) { | 8033 bool isMoreSpecificThan4(Type2 s, Set<Type2> visitedTypes, bool withDynamic, S
et<TypeImpl_TypePair> visitedTypePairs) { |
| 7768 int length = parameterTypes.length; | |
| 7769 for (int i = 0; i < length; i++) { | |
| 7770 if (parameterTypes[i] == this) { | |
| 7771 return argumentTypes[i]; | |
| 7772 } | |
| 7773 } | |
| 7774 return this; | |
| 7775 } | |
| 7776 | |
| 7777 bool isMoreSpecificThan4(Type2 s, Set<Type2> visitedTypes, bool withDynamic) { | |
| 7778 Type2 bound = element.bound; | 8034 Type2 bound = element.bound; |
| 7779 if (s == bound) { | 8035 if (s == bound) { |
| 7780 return true; | 8036 return true; |
| 7781 } | 8037 } |
| 7782 if (s.isObject) { | 8038 if (s.isObject) { |
| 7783 return true; | 8039 return true; |
| 7784 } | 8040 } |
| 7785 if (bound == null) { | 8041 if (bound == null) { |
| 7786 return false; | 8042 return false; |
| 7787 } | 8043 } |
| 7788 if (bound is TypeParameterTypeImpl) { | 8044 if (bound is TypeParameterTypeImpl) { |
| 7789 TypeParameterTypeImpl boundTypeParameter = bound as TypeParameterTypeImpl; | 8045 TypeParameterTypeImpl boundTypeParameter = bound as TypeParameterTypeImpl; |
| 7790 if (visitedTypes.contains(bound)) { | 8046 if (visitedTypes.contains(bound)) { |
| 7791 return false; | 8047 return false; |
| 7792 } | 8048 } |
| 7793 javaSetAdd(visitedTypes, bound); | 8049 visitedTypes.add(bound); |
| 7794 return boundTypeParameter.isMoreSpecificThan4(s, visitedTypes, withDynamic
); | 8050 return boundTypeParameter.isMoreSpecificThan4(s, visitedTypes, withDynamic
, visitedTypePairs); |
| 7795 } | 8051 } |
| 7796 return bound.isMoreSpecificThan3(s, withDynamic); | 8052 return (bound as TypeImpl).isMoreSpecificThan3(s, withDynamic, visitedTypePa
irs); |
| 7797 } | 8053 } |
| 7798 } | 8054 } |
| 7799 | 8055 |
| 7800 /** | 8056 /** |
| 7801 * The unique instance of the class `VoidTypeImpl` implements the type `void`. | 8057 * The unique instance of the class `VoidTypeImpl` implements the type `void`. |
| 7802 * | 8058 * |
| 7803 * @coverage dart.engine.type | 8059 * @coverage dart.engine.type |
| 7804 */ | 8060 */ |
| 7805 class VoidTypeImpl extends TypeImpl implements VoidType { | 8061 class VoidTypeImpl extends TypeImpl implements VoidType { |
| 7806 /** | 8062 /** |
| 7807 * The unique instance of this class. | 8063 * The unique instance of this class. |
| 7808 */ | 8064 */ |
| 7809 static final VoidTypeImpl instance = new VoidTypeImpl(); | 8065 static final VoidTypeImpl instance = new VoidTypeImpl(); |
| 7810 | 8066 |
| 7811 /** | 8067 /** |
| 7812 * Prevent the creation of instances of this class. | 8068 * Prevent the creation of instances of this class. |
| 7813 */ | 8069 */ |
| 7814 VoidTypeImpl() : super(null, Keyword.VOID.syntax); | 8070 VoidTypeImpl() : super(null, Keyword.VOID.syntax); |
| 7815 | 8071 |
| 7816 bool operator ==(Object object) => identical(object, this); | 8072 bool operator ==(Object object) => identical(object, this); |
| 7817 | 8073 |
| 7818 bool isMoreSpecificThan3(Type2 type, bool withDynamic) => isSubtypeOf(type); | |
| 7819 | |
| 7820 bool isSubtypeOf(Type2 type) => identical(type, this) || identical(type, Dynam
icTypeImpl.instance); | |
| 7821 | |
| 7822 bool get isVoid => true; | 8074 bool get isVoid => true; |
| 7823 | 8075 |
| 7824 VoidTypeImpl substitute2(List<Type2> argumentTypes, List<Type2> parameterTypes
) => this; | 8076 VoidTypeImpl substitute2(List<Type2> argumentTypes, List<Type2> parameterTypes
) => this; |
| 8077 |
| 8078 bool internalIsMoreSpecificThan(Type2 type, bool withDynamic, Set<TypeImpl_Typ
ePair> visitedTypePairs) => isSubtypeOf(type); |
| 8079 |
| 8080 bool internalIsSubtypeOf(Type2 type, Set<TypeImpl_TypePair> visitedTypePairs)
=> identical(type, this) || identical(type, DynamicTypeImpl.instance); |
| 7825 } | 8081 } |
| 7826 | 8082 |
| 7827 /** | 8083 /** |
| 7828 * The interface `FunctionType` defines the behavior common to objects represent
ing the type | 8084 * The interface `FunctionType` defines the behavior common to objects represent
ing the type |
| 7829 * of a function, method, constructor, getter, or setter. Function types come in
three variations: | 8085 * of a function, method, constructor, getter, or setter. Function types come in
three variations: |
| 7830 * <ol> | 8086 * <ol> |
| 7831 * * The types of functions that only have required parameters. These have the g
eneral form | 8087 * * The types of functions that only have required parameters. These have the g
eneral form |
| 7832 * <i>(T<sub>1</sub>, …, T<sub>n</sub>) → T</i>. | 8088 * <i>(T<sub>1</sub>, …, T<sub>n</sub>) → T</i>. |
| 7833 * * The types of functions with optional positional parameters. These have the
general form | 8089 * * The types of functions with optional positional parameters. These have the
general form |
| 7834 * <i>(T<sub>1</sub>, …, T<sub>n</sub>, [T<sub>n+1</sub>, …, T<sub
>n+k</sub>]) → | 8090 * <i>(T<sub>1</sub>, …, T<sub>n</sub>, [T<sub>n+1</sub>, …, T<sub
>n+k</sub>]) → |
| (...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8368 | 8624 |
| 8369 /** | 8625 /** |
| 8370 * Return `true` if this type is more specific than the given type. | 8626 * Return `true` if this type is more specific than the given type. |
| 8371 * | 8627 * |
| 8372 * @param type the type being compared with this type | 8628 * @param type the type being compared with this type |
| 8373 * @return `true` if this type is more specific than the given type | 8629 * @return `true` if this type is more specific than the given type |
| 8374 */ | 8630 */ |
| 8375 bool isMoreSpecificThan(Type2 type); | 8631 bool isMoreSpecificThan(Type2 type); |
| 8376 | 8632 |
| 8377 /** | 8633 /** |
| 8378 * Return `true` if this type is more specific than the given type. | |
| 8379 * | |
| 8380 * @param type the type being compared with this type | |
| 8381 * @param withDynamic `true` if "dynamic" should be considered as a subtype of
any type | |
| 8382 * @return `true` if this type is more specific than the given type | |
| 8383 */ | |
| 8384 bool isMoreSpecificThan3(Type2 type, bool withDynamic); | |
| 8385 | |
| 8386 /** | |
| 8387 * Return `true` if this type represents the type 'Object'. | 8634 * Return `true` if this type represents the type 'Object'. |
| 8388 * | 8635 * |
| 8389 * @return `true` if this type represents the type 'Object' | 8636 * @return `true` if this type represents the type 'Object' |
| 8390 */ | 8637 */ |
| 8391 bool get isObject; | 8638 bool get isObject; |
| 8392 | 8639 |
| 8393 /** | 8640 /** |
| 8394 * Return `true` if this type is a subtype of the given type. | 8641 * Return `true` if this type is a subtype of the given type. |
| 8395 * | 8642 * |
| 8396 * @param type the type being compared with this type | 8643 * @param type the type being compared with this type |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8442 | 8689 |
| 8443 /** | 8690 /** |
| 8444 * The interface `VoidType` defines the behavior of the unique object representi
ng the type | 8691 * The interface `VoidType` defines the behavior of the unique object representi
ng the type |
| 8445 * `void`. | 8692 * `void`. |
| 8446 * | 8693 * |
| 8447 * @coverage dart.engine.type | 8694 * @coverage dart.engine.type |
| 8448 */ | 8695 */ |
| 8449 abstract class VoidType implements Type2 { | 8696 abstract class VoidType implements Type2 { |
| 8450 VoidType substitute2(List<Type2> argumentTypes, List<Type2> parameterTypes); | 8697 VoidType substitute2(List<Type2> argumentTypes, List<Type2> parameterTypes); |
| 8451 } | 8698 } |
| OLD | NEW |