Chromium Code Reviews| Index: pkg/analyzer/lib/src/dart/element/type.dart |
| diff --git a/pkg/analyzer/lib/src/dart/element/type.dart b/pkg/analyzer/lib/src/dart/element/type.dart |
| index 7d08ca8d4638f7d68607841b99ec0ce9b46506fd..5f3be1714741c59de4ddedd190ac100221502c31 100644 |
| --- a/pkg/analyzer/lib/src/dart/element/type.dart |
| +++ b/pkg/analyzer/lib/src/dart/element/type.dart |
| @@ -24,6 +24,13 @@ import 'package:analyzer/src/generated/utilities_dart.dart'; |
| typedef FunctionTypedElement FunctionTypedElementComputer(); |
| /** |
| + * Computer of type arguments which is used to delay computing of type |
| + * arguments until they are requested, instead of at the [ParameterizedType] |
| + * creation time. |
| + */ |
| +typedef List<DartType> TypeArgumentsComputer(); |
| + |
| +/** |
| * A [Type] that represents the type 'bottom'. |
| */ |
| class BottomTypeImpl extends TypeImpl { |
| @@ -1117,7 +1124,13 @@ class InterfaceTypeImpl extends TypeImpl implements InterfaceType { |
| /** |
| * A list containing the actual types of the type arguments. |
| */ |
| - List<DartType> typeArguments = DartType.EMPTY_LIST; |
| + List<DartType> _typeArguments = DartType.EMPTY_LIST; |
| + |
| + /** |
| + * If not `null` and [_typeArguments] is `null`, the actual type arguments |
| + * should be computed (once) using this function. |
| + */ |
| + TypeArgumentsComputer _typeArgumentsComputer; |
| /** |
| * The set of typedefs which should not be expanded when exploring this type, |
| @@ -1136,10 +1149,10 @@ class InterfaceTypeImpl extends TypeImpl implements InterfaceType { |
| * with the given [name] and [typeArguments]. |
| */ |
| InterfaceTypeImpl.elementWithNameAndArgs( |
| - ClassElement element, String name, List<DartType> typeArguments) |
| + ClassElement element, String name, this._typeArgumentsComputer) |
| : prunedTypedefs = null, |
| super(element, name) { |
| - this.typeArguments = typeArguments; |
| + typeArguments = null; |
|
Paul Berry
2016/05/09 21:26:36
It seems weird to go through the setter here, sinc
|
| } |
| /** |
| @@ -1301,6 +1314,21 @@ class InterfaceTypeImpl extends TypeImpl implements InterfaceType { |
| } |
| @override |
| + List<DartType> get typeArguments { |
| + if (_typeArguments == null) { |
| + _typeArguments = _typeArgumentsComputer(); |
| + } |
| + return _typeArguments; |
| + } |
| + |
| + /** |
| + * Set [typeArguments]. |
| + */ |
| + void set typeArguments(List<DartType> typeArguments) { |
| + _typeArguments = typeArguments; |
|
Paul Berry
2016/05/09 21:26:36
To facilitate garbage collection I would recommend
|
| + } |
| + |
| + @override |
| List<TypeParameterElement> get typeParameters => element.typeParameters; |
| @override |