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

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

Issue 2661123002: Don't resynthesize field types during class members resynthesis. (Closed)
Patch Set: Created 3 years, 11 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/summarize_ast.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 c90c7c3b8f0a6b1846e33955b2158f2887a769ac..7ecd4391f6a8ae2b7d50b29aefb05261c945cff2 100644
--- a/pkg/analyzer/lib/src/dart/element/element.dart
+++ b/pkg/analyzer/lib/src/dart/element/element.dart
@@ -1208,16 +1208,6 @@ class ClassElementImpl extends AbstractClassElementImpl
PropertyAccessorElementImpl accessor =
new PropertyAccessorElementImpl.forSerialized(e, this);
explicitAccessors.add(accessor);
- // Prepare the field type.
- DartType fieldType;
- if (e.kind == UnlinkedExecutableKind.getter) {
- fieldType = accessor.returnType;
- } else {
- List<ParameterElement> parameters = accessor.parameters;
- fieldType = parameters.isNotEmpty
- ? parameters[0].type
- : DynamicTypeImpl.instance;
- }
// Create or update the implicit field.
String fieldName = accessor.displayName;
FieldElementImpl field = implicitFields[fieldName];
@@ -1227,7 +1217,6 @@ class ClassElementImpl extends AbstractClassElementImpl
field.enclosingElement = this;
field.isSynthetic = true;
field.isFinal = e.kind == UnlinkedExecutableKind.getter;
- field.type = fieldType;
field.isStatic = e.isStatic;
} else {
field.isFinal = false;
@@ -6907,6 +6896,7 @@ abstract class NonParameterVariableElementImpl extends VariableElementImpl {
return super.type;
}
+ @override
void set type(DartType type) {
_assertNotResynthesized(_unlinkedVariable);
_type = type;
@@ -7887,6 +7877,23 @@ abstract class PropertyInducingElementImpl
_assertNotResynthesized(_unlinkedVariable);
_propagatedType = propagatedType;
}
+
+ @override
+ DartType get type {
+ if (isSynthetic && _type == null) {
+ if (getter != null) {
+ _type = getter.returnType;
+ } else if (setter != null) {
+ List<ParameterElement> parameters = setter.parameters;
+ _type = parameters.isNotEmpty
+ ? parameters[0].type
+ : DynamicTypeImpl.instance;
+ } else {
+ _type = DynamicTypeImpl.instance;
+ }
+ }
+ return super.type;
+ }
}
/**
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/summary/summarize_ast.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698