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

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

Issue 2007323006: Resynthesize return types lazily. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: 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/resynthesize.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 d407317ca9a387796d8cb3b4fde008baedbf31a0..1d8e87e8121ef7866f114cea3a239da442ea951f 100644
--- a/pkg/analyzer/lib/src/dart/element/element.dart
+++ b/pkg/analyzer/lib/src/dart/element/element.dart
@@ -1682,6 +1682,9 @@ class ConstructorElementImpl extends ExecutableElementImpl
ElementKind get kind => ElementKind.CONSTRUCTOR;
@override
+ DartType get returnType => enclosingElement.type;
+
+ @override
accept(ElementVisitor visitor) => visitor.visitConstructorElement(this);
@override
@@ -2806,7 +2809,7 @@ abstract class ExecutableElementImpl extends ElementImpl
/**
* The return type defined by this executable element.
*/
- DartType returnType;
+ DartType _returnType;
/**
* The type of function defined by this executable element.
@@ -3040,6 +3043,26 @@ abstract class ExecutableElementImpl extends ElementImpl
}
@override
+ DartType get returnType {
+ if (serializedExecutable != null && _returnType == null) {
+ bool isSetter =
+ serializedExecutable.kind == UnlinkedExecutableKind.setter;
+ _returnType = enclosingUnit.resynthesizerContext.resolveLinkedType(
+ serializedExecutable.inferredReturnTypeSlot,
+ typeParameterContext) ??
+ enclosingUnit.resynthesizerContext.resolveTypeRef(
+ serializedExecutable.returnType, typeParameterContext,
+ defaultVoid: isSetter && context.analysisOptions.strongMode);
+ }
+ return _returnType;
+ }
+
+ void set returnType(DartType returnType) {
+ assert(serializedExecutable == null);
+ _returnType = returnType;
+ }
+
+ @override
TypeParameterizedElementMixin get typeParameterContext => this;
@override
@@ -3631,7 +3654,7 @@ class FunctionTypeAliasElementImpl extends ElementImpl
/**
* The return type defined by this type alias.
*/
- DartType returnType;
+ DartType _returnType;
/**
* The type of function defined by this type alias.
@@ -3762,6 +3785,20 @@ class FunctionTypeAliasElementImpl extends ElementImpl
}
@override
+ DartType get returnType {
+ if (_unlinkedTypedef != null && _returnType == null) {
+ _returnType = enclosingUnit.resynthesizerContext
+ .resolveTypeRef(_unlinkedTypedef.returnType, this);
+ }
+ return _returnType;
+ }
+
+ void set returnType(DartType returnType) {
+ assert(_unlinkedTypedef == null);
+ _returnType = returnType;
+ }
+
+ @override
TypeParameterizedElementMixin get typeParameterContext => this;
@override
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/summary/resynthesize.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698