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

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

Issue 2038153003: Create ClassElement.type lazily in ClassElementImpl and EnumElementImpl. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 6 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
Index: pkg/analyzer/lib/src/dart/element/element.dart
diff --git a/pkg/analyzer/lib/src/dart/element/element.dart b/pkg/analyzer/lib/src/dart/element/element.dart
index afe5715ba97dadc724b53fe9e668859bc36933f0..94571086976362e5e5a202d3b79a7e60505a3b45 100644
--- a/pkg/analyzer/lib/src/dart/element/element.dart
+++ b/pkg/analyzer/lib/src/dart/element/element.dart
@@ -49,12 +49,6 @@ abstract class AbstractClassElementImpl extends ElementImpl
List<FieldElement> _fields;
/**
- * The type defined by the class.
- */
- @override
- InterfaceType type;
-
- /**
* Initialize a newly created class element to have the given [name] at the
* given [offset] in the file that contains the declaration of this element.
*/
@@ -441,6 +435,11 @@ class ClassElementImpl extends AbstractClassElementImpl
InterfaceType _supertype;
/**
+ * The type defined by the class.
+ */
+ InterfaceType _type;
+
+ /**
* A list containing all of the mixins that are applied to the class being
* extended in order to derive the superclass of this class.
*/
@@ -877,6 +876,16 @@ class ClassElementImpl extends AbstractClassElementImpl
}
@override
+ InterfaceType get type {
+ if (_type == null) {
+ InterfaceTypeImpl type = new InterfaceTypeImpl(this);
+ type.typeArguments = typeParameterTypes;
+ _type = type;
+ }
+ return _type;
+ }
+
+ @override
TypeParameterizedElementMixin get typeParameterContext => this;
@override
@@ -3128,6 +3137,11 @@ class EnumElementImpl extends AbstractClassElementImpl {
final UnlinkedEnum _unlinkedEnum;
/**
+ * The type defined by the enum.
+ */
+ InterfaceType _type;
+
+ /**
* Initialize a newly created class element to have the given [name] at the
* given [offset] in the file that contains the declaration of this element.
*/
@@ -3268,6 +3282,16 @@ class EnumElementImpl extends AbstractClassElementImpl {
InterfaceType get supertype => context.typeProvider.objectType;
@override
+ InterfaceType get type {
+ if (_type == null) {
+ InterfaceTypeImpl type = new InterfaceTypeImpl(this);
+ type.typeArguments = const <DartType>[];
+ _type = type;
+ }
+ return _type;
+ }
+
+ @override
List<TypeParameterElement> get typeParameters =>
const <TypeParameterElement>[];
« no previous file with comments | « pkg/analyzer/lib/src/dart/element/builder.dart ('k') | pkg/analyzer/lib/src/generated/testing/element_factory.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698