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

Unified Diff: pkg/analyzer/lib/src/summary/resynthesize.dart

Issue 2016543002: Resynthesize FieldFormalParameterElementImpl(s) 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
Index: pkg/analyzer/lib/src/summary/resynthesize.dart
diff --git a/pkg/analyzer/lib/src/summary/resynthesize.dart b/pkg/analyzer/lib/src/summary/resynthesize.dart
index 14682443fb5167df1b4f91bcd0ad316d72a4d23a..123385a688d3f96648bd2f8732c3299940425998 100644
--- a/pkg/analyzer/lib/src/summary/resynthesize.dart
+++ b/pkg/analyzer/lib/src/summary/resynthesize.dart
@@ -1546,6 +1546,12 @@ class _ResynthesizerContext implements ResynthesizerContext {
}
@override
+ DartType resolveLinkedType(
+ int slot, TypeParameterizedElementMixin typeParameterContext) {
+ return _unitResynthesizer.buildLinkedType(slot, typeParameterContext);
+ }
+
+ @override
DartType resolveTypeRef(
EntityRef type, TypeParameterizedElementMixin typeParameterContext,
{bool defaultVoid: false, bool instantiateToBoundsAllowed: true}) {
@@ -2108,10 +2114,8 @@ class _UnitResynthesizer {
bool isSetter =
serializedExecutable.kind == UnlinkedExecutableKind.setter;
executableElement.returnType = buildLinkedType(
- serializedExecutable.inferredReturnTypeSlot,
- _currentTypeParameterizedElement) ??
- buildType(
- serializedExecutable.returnType, _currentTypeParameterizedElement,
+ serializedExecutable.inferredReturnTypeSlot, executableElement) ??
+ buildType(serializedExecutable.returnType, executableElement,
defaultVoid: isSetter && summaryResynthesizer.strongMode);
}
executableElement.type = new FunctionTypeImpl.elementWithNameAndArgs(
@@ -2319,49 +2323,35 @@ class _UnitResynthesizer {
UnlinkedParam serializedParameter, ElementImpl enclosingElement,
{bool synthetic: false}) {
ParameterElementImpl parameterElement;
- bool isLazilyResynthesized = false;
- int nameOffset = synthetic ? -1 : serializedParameter.nameOffset;
if (serializedParameter.isInitializingFormal) {
FieldFormalParameterElementImpl initializingParameter;
if (serializedParameter.kind == UnlinkedParamKind.required) {
- initializingParameter = new FieldFormalParameterElementImpl(
- serializedParameter.name, nameOffset);
+ initializingParameter =
+ new FieldFormalParameterElementImpl.forSerialized(
+ serializedParameter, enclosingElement);
} else {
- DefaultFieldFormalParameterElementImpl defaultParameter =
- new DefaultFieldFormalParameterElementImpl(
- serializedParameter.name, nameOffset);
- initializingParameter = defaultParameter;
- if (serializedParameter.defaultValue != null) {
- defaultParameter.constantInitializer = _buildConstExpression(
- enclosingElement, serializedParameter.defaultValue);
- defaultParameter.defaultValueCode =
- serializedParameter.defaultValueCode;
- }
+ initializingParameter =
+ new DefaultFieldFormalParameterElementImpl.forSerialized(
+ serializedParameter, enclosingElement);
}
parameterElement = initializingParameter;
- initializingParameter.field = fields[serializedParameter.name];
} else {
if (serializedParameter.kind == UnlinkedParamKind.required) {
parameterElement = new ParameterElementImpl.forSerialized(
serializedParameter, enclosingElement);
- isLazilyResynthesized = true;
} else {
- DefaultParameterElementImpl defaultParameter =
- new DefaultParameterElementImpl.forSerialized(
- serializedParameter, enclosingElement);
- isLazilyResynthesized = true;
- parameterElement = defaultParameter;
+ parameterElement = new DefaultParameterElementImpl.forSerialized(
+ serializedParameter, enclosingElement);
}
}
parameterElement.synthetic = synthetic;
- if (!isLazilyResynthesized) {
- buildAnnotations(parameterElement, serializedParameter.annotations);
- buildCodeRange(parameterElement, serializedParameter.codeRange);
- }
if (serializedParameter.isFunctionTyped) {
FunctionElementImpl parameterTypeElement =
- new FunctionElementImpl('', -1);
- parameterTypeElement.synthetic = true;
+ new FunctionElementImpl_forFunctionTypedParameter(
+ unit, parameterElement);
+ if (!synthetic) {
+ parameterTypeElement.enclosingElement = parameterElement;
+ }
List<ParameterElement> subParameters = serializedParameter.parameters
.map((UnlinkedParam p) =>
buildParameter(p, parameterTypeElement, synthetic: synthetic))
@@ -2371,29 +2361,12 @@ class _UnitResynthesizer {
} else {
parameterElement.parameters = subParameters;
parameterTypeElement.shareParameters(subParameters);
- parameterTypeElement.enclosingElement = parameterElement;
}
parameterTypeElement.returnType =
buildType(serializedParameter.type, _currentTypeParameterizedElement);
parameterElement.type = new FunctionTypeImpl.elementWithNameAndArgs(
parameterTypeElement, null, getCurrentTypeArguments(), false);
parameterTypeElement.type = parameterElement.type;
- } else {
- if (serializedParameter.isInitializingFormal &&
- serializedParameter.type == null) {
- // The type is inherited from the matching field.
- parameterElement.type =
- fields[serializedParameter.name]?.type ?? DynamicTypeImpl.instance;
- } else {
- parameterElement.type = buildLinkedType(
- serializedParameter.inferredTypeSlot,
- _currentTypeParameterizedElement) ??
- buildType(
- serializedParameter.type, _currentTypeParameterizedElement);
- }
- if (!isLazilyResynthesized) {
- parameterElement.hasImplicitType = serializedParameter.type == null;
- }
}
buildVariableInitializer(parameterElement, serializedParameter.initializer);
switch (serializedParameter.kind) {
@@ -2407,12 +2380,6 @@ class _UnitResynthesizer {
parameterElement.parameterKind = ParameterKind.REQUIRED;
break;
}
- if (!isLazilyResynthesized) {
- if (serializedParameter.visibleOffset != 0) {
- parameterElement.setVisibleRange(serializedParameter.visibleOffset,
- serializedParameter.visibleLength);
- }
- }
return parameterElement;
}
@@ -2461,8 +2428,8 @@ class _UnitResynthesizer {
if (type.paramReference != 0) {
return typeParameterContext.getTypeParameterType(type.paramReference);
} else if (type.syntheticReturnType != null) {
- FunctionElementImpl element = new FunctionElementImpl('', -1);
- element.synthetic = true;
+ FunctionElementImpl element =
+ new FunctionElementImpl_forLUB(unit, typeParameterContext);
element.parameters = type.syntheticParams
.map((UnlinkedParam param) =>
buildParameter(param, element, synthetic: true))
@@ -2674,8 +2641,8 @@ class _UnitResynthesizer {
void buildVariableCommonParts(
VariableElementImpl element, UnlinkedVariable serializedVariable) {
element.type = buildLinkedType(serializedVariable.inferredTypeSlot,
- _currentTypeParameterizedElement) ??
- buildType(serializedVariable.type, _currentTypeParameterizedElement);
+ element.typeParameterContext) ??
+ buildType(serializedVariable.type, element.typeParameterContext);
buildVariableInitializer(element, serializedVariable.initializer);
}

Powered by Google App Engine
This is Rietveld 408576698