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

Unified Diff: pkg/analyzer/lib/src/dart/element/type.dart

Issue 1963593003: Implement 'instantiate to bounds' feature in resynthesizer. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Fixes for review comments. Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/summary/link.dart » ('j') | pkg/analyzer/lib/src/summary/link.dart » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..f2e9a1507d8344a997875271008fffe4bb35f0de 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;
}
/**
@@ -1301,6 +1314,23 @@ class InterfaceTypeImpl extends TypeImpl implements InterfaceType {
}
@override
+ List<DartType> get typeArguments {
+ if (_typeArguments == null) {
+ _typeArguments = _typeArgumentsComputer();
+ _typeArgumentsComputer = null;
+ }
+ return _typeArguments;
+ }
+
+ /**
+ * Set [typeArguments].
+ */
+ void set typeArguments(List<DartType> typeArguments) {
+ _typeArguments = typeArguments;
+ _typeArgumentsComputer = null;
+ }
+
+ @override
List<TypeParameterElement> get typeParameters => element.typeParameters;
@override
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/summary/link.dart » ('j') | pkg/analyzer/lib/src/summary/link.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698