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

Side by Side Diff: pkg/analyzer/lib/dart/element/type.dart

Issue 2208953002: fix #25944, improve Future.then inference (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: cleanup unused code Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /** 5 /**
6 * Defines the type model. The type model is part of the 6 * Defines the type model. The type model is part of the
7 * [element model](element.dart) in that most types are defined by Dart code 7 * [element model](element.dart) in that most types are defined by Dart code
8 * (the types `dynamic` and `void` being the notable exceptions). All types are 8 * (the types `dynamic` and `void` being the notable exceptions). All types are
9 * represented by an instance of a subclass of [DartType]. 9 * represented by an instance of a subclass of [DartType].
10 * 10 *
11 * Other than `dynamic` and `void`, all of the types define either the interface 11 * Other than `dynamic` and `void`, all of the types define either the interface
12 * defined by a class (an instance of [InterfaceType]) or the type of a function 12 * defined by a class (an instance of [InterfaceType]) or the type of a function
13 * (an instance of [FunctionType]). 13 * (an instance of [FunctionType]).
14 * 14 *
15 * We make a distinction between the declaration of a class (a [ClassElement]) 15 * We make a distinction between the declaration of a class (a [ClassElement])
16 * and the type defined by that class (an [InterfaceType]). The biggest reason 16 * and the type defined by that class (an [InterfaceType]). The biggest reason
17 * for the distinction is to allow us to more cleanly represent the distinction 17 * for the distinction is to allow us to more cleanly represent the distinction
18 * between type parameters and type arguments. For example, if we define a class 18 * between type parameters and type arguments. For example, if we define a class
19 * as `class Pair<K, V> {}`, the declarations of `K` and `V` represent type 19 * as `class Pair<K, V> {}`, the declarations of `K` and `V` represent type
20 * parameters. But if we declare a variable as `Pair<String, int> pair;` the 20 * parameters. But if we declare a variable as `Pair<String, int> pair;` the
21 * references to `String` and `int` are type arguments. 21 * references to `String` and `int` are type arguments.
22 */ 22 */
23 library analyzer.dart.element.type; 23 library analyzer.dart.element.type;
24 24
25 import 'package:analyzer/dart/element/element.dart'; 25 import 'package:analyzer/dart/element/element.dart';
26 import 'package:analyzer/src/dart/element/type.dart' show InterfaceTypeImpl; 26 import 'package:analyzer/src/dart/element/type.dart' show InterfaceTypeImpl;
27 import 'package:analyzer/src/generated/type_system.dart' show TypeSystem; 27 import 'package:analyzer/src/generated/type_system.dart'
28 show TypeContext, TypeSystem;
28 29
29 /** 30 /**
30 * The type associated with elements in the element model. 31 * The type associated with elements in the element model.
31 * 32 *
32 * Clients may not extend, implement or mix-in this class. 33 * Clients may not extend, implement or mix-in this class.
33 */ 34 */
34 abstract class DartType { 35 abstract class DartType implements TypeContext {
Leaf 2016/08/05 22:32:35 It bothers me a bit that this leaks into the publi
Jennifer Messerly 2016/08/08 21:59:26 Yeah, making it a subtype of TypeImpl works for me
35 /** 36 /**
36 * An empty list of types. 37 * An empty list of types.
37 */ 38 */
38 static const List<DartType> EMPTY_LIST = const <DartType>[]; 39 static const List<DartType> EMPTY_LIST = const <DartType>[];
39 40
40 /** 41 /**
41 * Return the name of this type as it should appear when presented to users in 42 * Return the name of this type as it should appear when presented to users in
42 * contexts such as error messages. 43 * contexts such as error messages.
43 */ 44 */
44 String get displayName; 45 String get displayName;
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 * 284 *
284 * * For all <i>i</i>, 1 <= <i>i</i> <= <i>n</i>, <i>T<sub>i</sub> &hArr; 285 * * For all <i>i</i>, 1 <= <i>i</i> <= <i>n</i>, <i>T<sub>i</sub> &hArr;
285 * S<sub>i</sub></i>. 286 * S<sub>i</sub></i>.
286 * * <i>k</i> >= <i>m</i> and <i>y<sub>i</sub></i> in <i>{x<sub>1</sub>, 287 * * <i>k</i> >= <i>m</i> and <i>y<sub>i</sub></i> in <i>{x<sub>1</sub>,
287 * &hellip;, x<sub>k</sub>}</i>, 1 <= <i>i</i> <= <i>m</i>. 288 * &hellip;, x<sub>k</sub>}</i>, 1 <= <i>i</i> <= <i>m</i>.
288 * * For all <i>y<sub>i</sub></i> in <i>{y<sub>1</sub>, &hellip;, 289 * * For all <i>y<sub>i</sub></i> in <i>{y<sub>1</sub>, &hellip;,
289 * y<sub>m</sub>}</i>, <i>y<sub>i</sub> = x<sub>j</sub> => Tj &hArr; Si</i>. 290 * y<sub>m</sub>}</i>, <i>y<sub>i</sub> = x<sub>j</sub> => Tj &hArr; Si</i>.
290 * 291 *
291 * In addition, the following subtype rules apply: 292 * In addition, the following subtype rules apply:
292 * 293 *
293 * <i>(T<sub>1</sub>, &hellip;, T<sub>n</sub>, []) &rarr; T <: (T<sub>1</sub>, 294 * <i>(T<sub>1</sub>, &hellip;, T<sub>n</sub>, `[]`) &rarr; T <: (T<sub>1</sub >,
Leaf 2016/08/05 22:32:35 line length.
Jennifer Messerly 2016/08/08 21:59:26 Done.
294 * &hellip;, T<sub>n</sub>) &rarr; T.</i><br> 295 * &hellip;, T<sub>n</sub>) &rarr; T.</i><br>
295 * <i>(T<sub>1</sub>, &hellip;, T<sub>n</sub>) &rarr; T <: (T<sub>1</sub>, 296 * <i>(T<sub>1</sub>, &hellip;, T<sub>n</sub>) &rarr; T <: (T<sub>1</sub>,
296 * &hellip;, T<sub>n</sub>, {}) &rarr; T.</i><br> 297 * &hellip;, T<sub>n</sub>, {}) &rarr; T.</i><br>
297 * <i>(T<sub>1</sub>, &hellip;, T<sub>n</sub>, {}) &rarr; T <: (T<sub>1</sub>, 298 * <i>(T<sub>1</sub>, &hellip;, T<sub>n</sub>, {}) &rarr; T <: (T<sub>1</sub>,
298 * &hellip;, T<sub>n</sub>) &rarr; T.</i><br> 299 * &hellip;, T<sub>n</sub>) &rarr; T.</i><br>
299 * <i>(T<sub>1</sub>, &hellip;, T<sub>n</sub>) &rarr; T <: (T<sub>1</sub>, 300 * <i>(T<sub>1</sub>, &hellip;, T<sub>n</sub>) &rarr; T <: (T<sub>1</sub>,
300 * &hellip;, T<sub>n</sub>, []) &rarr; T.</i> 301 * &hellip;, T<sub>n</sub>, []) &rarr; T.</i>
301 * 302 *
302 * All functions implement the class `Function`. However not all function 303 * All functions implement the class `Function`. However not all function
303 * types are a subtype of `Function`. If an interface type <i>I</i> includes a 304 * types are a subtype of `Function`. If an interface type <i>I</i> includes a
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
694 */ 695 */
695 abstract class TypeParameterType implements DartType { 696 abstract class TypeParameterType implements DartType {
696 /** 697 /**
697 * An empty list of type parameter types. 698 * An empty list of type parameter types.
698 */ 699 */
699 static const List<TypeParameterType> EMPTY_LIST = const <TypeParameterType>[]; 700 static const List<TypeParameterType> EMPTY_LIST = const <TypeParameterType>[];
700 701
701 @override 702 @override
702 TypeParameterElement get element; 703 TypeParameterElement get element;
703 } 704 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/generated/resolver.dart » ('j') | pkg/analyzer/lib/src/generated/resolver.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698