OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 // This code was auto-generated, is not intended to be edited, and is subject to | 5 // This code was auto-generated, is not intended to be edited, and is subject to |
6 // significant change. Please see the README file for more information. | 6 // significant change. Please see the README file for more information. |
7 | 7 |
8 library engine.element; | 8 library engine.element; |
9 | 9 |
10 import 'dart:collection'; | 10 import 'dart:collection'; |
(...skipping 5267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5278 * An array containing the actual types of the type arguments. | 5278 * An array containing the actual types of the type arguments. |
5279 */ | 5279 */ |
5280 List<DartType> typeArguments = TypeImpl.EMPTY_ARRAY; | 5280 List<DartType> typeArguments = TypeImpl.EMPTY_ARRAY; |
5281 | 5281 |
5282 /** | 5282 /** |
5283 * Initialize a newly created function type to be declared by the given elemen
t and to have the | 5283 * Initialize a newly created function type to be declared by the given elemen
t and to have the |
5284 * given name. | 5284 * given name. |
5285 * | 5285 * |
5286 * @param element the element representing the declaration of the function typ
e | 5286 * @param element the element representing the declaration of the function typ
e |
5287 */ | 5287 */ |
5288 FunctionTypeImpl.con1(ExecutableElement element) : super(element, element == n
ull ? null : element.name); | 5288 FunctionTypeImpl.con1(ExecutableElement element) : super(element, null); |
5289 | 5289 |
5290 /** | 5290 /** |
5291 * Initialize a newly created function type to be declared by the given elemen
t and to have the | 5291 * Initialize a newly created function type to be declared by the given elemen
t and to have the |
5292 * given name. | 5292 * given name. |
5293 * | 5293 * |
5294 * @param element the element representing the declaration of the function typ
e | 5294 * @param element the element representing the declaration of the function typ
e |
5295 */ | 5295 */ |
5296 FunctionTypeImpl.con2(FunctionTypeAliasElement element) : super(element, eleme
nt == null ? null : element.name); | 5296 FunctionTypeImpl.con2(FunctionTypeAliasElement element) : super(element, eleme
nt == null ? null : element.name); |
5297 | 5297 |
5298 @override | 5298 @override |
(...skipping 5811 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11110 Set<DartType> get elements; | 11110 Set<DartType> get elements; |
11111 } | 11111 } |
11112 | 11112 |
11113 /** | 11113 /** |
11114 * In addition to the methods of the `UnionType` interface we add a factory meth
od | 11114 * In addition to the methods of the `UnionType` interface we add a factory meth
od |
11115 * `union` for building unions. | 11115 * `union` for building unions. |
11116 */ | 11116 */ |
11117 class UnionTypeImpl extends TypeImpl implements UnionType { | 11117 class UnionTypeImpl extends TypeImpl implements UnionType { |
11118 /** | 11118 /** |
11119 * Any unions in the `types` will be flattened in the returned union. If there
is only one | 11119 * Any unions in the `types` will be flattened in the returned union. If there
is only one |
11120 * type after flattening then it will be returned directly, instead of a singl
eton union. | 11120 * type after flattening then it will be returned directly, instead of a singl
eton union. Nulls |
| 11121 * are discarded, unless all types are null, in which case an exception is rai
sed. |
11121 * | 11122 * |
11122 * @param types the `Type`s to union | 11123 * @param types the `Type`s to union |
11123 * @return a `Type` comprising the `Type`s in `types` | 11124 * @return a `Type` comprising the `Type`s in `types` |
11124 */ | 11125 */ |
11125 static DartType union(List<DartType> types) { | 11126 static DartType union(List<DartType> types) { |
11126 Set<DartType> set = new HashSet<DartType>(); | 11127 Set<DartType> set = new HashSet<DartType>(); |
11127 for (DartType t in types) { | 11128 for (DartType t in types) { |
11128 if (t is UnionType) { | 11129 if (t is UnionType) { |
11129 set.addAll(t.elements); | 11130 set.addAll(t.elements); |
11130 } else { | 11131 } else { |
11131 set.add(t); | 11132 if (t != null) { |
| 11133 set.add(t); |
| 11134 } |
11132 } | 11135 } |
11133 } | 11136 } |
11134 if (set.length == 0) { | 11137 if (set.length == 0) { |
| 11138 // TODO(collinsn): better to return [null] here? The use case is e.g. |
| 11139 // |
| 11140 // union(null, null) ==> null; |
| 11141 // |
| 11142 // instead of raising an exception. |
11135 throw new IllegalArgumentException("No known use case for empty unions."); | 11143 throw new IllegalArgumentException("No known use case for empty unions."); |
11136 } else if (set.length == 1) { | 11144 } else if (set.length == 1) { |
11137 return new JavaIterator(set).next(); | 11145 return new JavaIterator(set).next(); |
11138 } else { | 11146 } else { |
11139 return new UnionTypeImpl(set); | 11147 return new UnionTypeImpl(set); |
11140 } | 11148 } |
11141 } | 11149 } |
11142 | 11150 |
11143 /** | 11151 /** |
11144 * The types in this union. | 11152 * The types in this union. |
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11635 if (type is UnionType) { | 11643 if (type is UnionType) { |
11636 return (type as UnionTypeImpl).internalUnionTypeIsSuperTypeOf(this, visite
dTypePairs); | 11644 return (type as UnionTypeImpl).internalUnionTypeIsSuperTypeOf(this, visite
dTypePairs); |
11637 } | 11645 } |
11638 // The only subtype relations that pertain to void are therefore: | 11646 // The only subtype relations that pertain to void are therefore: |
11639 // void <: void (by reflexivity) | 11647 // void <: void (by reflexivity) |
11640 // bottom <: void (as bottom is a subtype of all types). | 11648 // bottom <: void (as bottom is a subtype of all types). |
11641 // void <: dynamic (as dynamic is a supertype of all types) | 11649 // void <: dynamic (as dynamic is a supertype of all types) |
11642 return identical(type, this) || identical(type, DynamicTypeImpl.instance); | 11650 return identical(type, this) || identical(type, DynamicTypeImpl.instance); |
11643 } | 11651 } |
11644 } | 11652 } |
OLD | NEW |