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

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

Issue 2551023005: Prepare for decoupling analyzer ASTs from element model. (Closed)
Patch Set: Address review comments Created 4 years 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/ast/resolution_base_classes.dart';
25 import 'package:analyzer/dart/element/element.dart'; 26 import 'package:analyzer/dart/element/element.dart';
26 import 'package:analyzer/src/dart/element/type.dart' show InterfaceTypeImpl; 27 import 'package:analyzer/src/dart/element/type.dart' show InterfaceTypeImpl;
27 import 'package:analyzer/src/generated/type_system.dart' show TypeSystem; 28 import 'package:analyzer/src/generated/type_system.dart' show 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 ResolutionType {
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 646 matching lines...) Expand 10 before | Expand all | Expand 10 after
691 * The type introduced by a type parameter. 692 * The type introduced by a type parameter.
692 * 693 *
693 * Clients may not extend, implement or mix-in this class. 694 * Clients may not extend, implement or mix-in this class.
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 TypeParameterElement get element;
703
704 /** 702 /**
705 * Return the type representing the bound associated with this parameter, 703 * Return the type representing the bound associated with this parameter,
706 * or `dynamic` if there was no explicit bound. 704 * or `dynamic` if there was no explicit bound.
707 */ 705 */
708 DartType get bound; 706 DartType get bound;
709 707
710 /** 708 /**
711 * An object that can be used to identify this type parameter with `==`. 709 * An object that can be used to identify this type parameter with `==`.
712 * 710 *
713 * Depending on the use, [bound] may also need to be taken into account. 711 * Depending on the use, [bound] may also need to be taken into account.
714 * A given type parameter, it may have different bounds in different scopes. 712 * A given type parameter, it may have different bounds in different scopes.
715 * Always consult the bound if that could be relevant. 713 * Always consult the bound if that could be relevant.
716 */ 714 */
717 ElementLocation get definition; 715 ElementLocation get definition;
716
717 @override
718 TypeParameterElement get element;
718 } 719 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698