Chromium Code Reviews| Index: pkg/analyzer/lib/dart/element/type.dart |
| diff --git a/pkg/analyzer/lib/dart/element/type.dart b/pkg/analyzer/lib/dart/element/type.dart |
| index 49607dc2c65b46d30b59d8f13740cc42b390b909..1090ce816588f9503ecbb66e521ae8ea2ca1195d 100644 |
| --- a/pkg/analyzer/lib/dart/element/type.dart |
| +++ b/pkg/analyzer/lib/dart/element/type.dart |
| @@ -131,13 +131,20 @@ abstract class DartType { |
| */ |
| abstract class FunctionType implements ParameterizedType { |
| /** |
| - * The type parameters of this generic function. For example `<T> T -> T`. |
| + * Deprecated: use [typeFormals]. |
| + */ |
| + @deprecated |
| + List<TypeParameterElement> get boundTypeParameters; |
| + |
| + /** |
| + * The formal type parameters of this generic function. |
| + * For example `<T> T -> T`. |
| * |
| * These are distinct from the [typeParameters] list, which contains type |
| * parameters from surrounding contexts, and thus are free type variables from |
| * the perspective of this function type. |
| */ |
| - List<TypeParameterElement> get boundTypeParameters; |
| + List<TypeParameterElement> get typeFormals; |
| /** |
| * Return a map from the names of named parameters to the types of the named |
| @@ -569,7 +576,7 @@ abstract class InterfaceType implements ParameterizedType { |
| */ |
| // TODO(jmesserly): introduce a new "instantiate" and deprecate this. |
| // The new "instantiate" should work similar to FunctionType.instantiate, |
| - // which uses [boundTypeParameters] to model type parameters that haven't been |
| + // which uses [typeFormals] to model type parameters that haven't been |
| // filled in yet. Those are kept separate from already-substituted type |
| // parameters or free variables from the enclosing scopes, which allows nested |
| // generics to work, such as a generic method in a generic class. |
| @@ -590,11 +597,28 @@ abstract class InterfaceType implements ParameterizedType { |
| } |
| /** |
| - * A type with type parameters, such as a class or function type alias. |
| + * A type that can track substituted type parameters, either for itself after |
| + * instantiation, or from a surrounding context. |
| + * |
| + * For example, given a class `Foo<T>`, after instantiation with S for T, it |
| + * will track the substitution `{S/T}`. This substitution will be propegated |
|
Brian Wilkerson
2016/01/06 21:57:34
"propegated" --> "propagated"
Jennifer Messerly
2016/01/06 22:25:51
Thanks, done. For some reason I spell that word wr
|
| + * to its members. For example, we can also for the "foo" field declared as |
|
Brian Wilkerson
2016/01/06 21:57:34
Is "we can also for the" missing something between
Jennifer Messerly
2016/01/06 22:25:51
Doh, yeah that comment was really bad. I think thi
|
| + * `T foo;` and we'll get back a [FieldMember] with type represented as |
| + * `{S/T}T` which equals `S`. |
| * |
| * Clients may not extend, implement or mix-in this class. |
| */ |
| abstract class ParameterizedType implements DartType { |
| + // TODO(jmesserly): rename to substitutedTypeArguments and |
| + // substitutedTypeParameters? Alternatively we could remove the |
|
Brian Wilkerson
2016/01/06 21:57:34
Not sure what the value of adding "substituted" to
Jennifer Messerly
2016/01/06 22:25:51
Agreed. Let me remove this TODO. It was added befo
|
| + // "implements DartType", make it non-abstract, and rename this to |
| + // TypeSubstitution. |
|
Brian Wilkerson
2016/01/06 21:57:34
I don't want to make this non-abstract because all
Jennifer Messerly
2016/01/06 22:25:51
Agreed, I will remove this comment.
|
| + // |
| + // At that point, we can leave things like ClassElement implementing it too. |
| + // The next step would be to favor containment over inheritance, and pull it |
| + // out of Elements and Types altogether, which has the side effect of making |
| + // it easier to share and pass around as a unit. |
| + |
| /** |
| * Return a list containing the actual types of the type arguments. If this |
| * type's element does not have type parameters, then the array should be |