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

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

Issue 2814163002: Revert "Pass ElementImpl as a context for resynthesizing types." (Closed)
Patch Set: Created 3 years, 8 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 | « pkg/analyzer/lib/src/summary/link.dart ('k') | pkg/analyzer/test/src/summary/resynthesize_common.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 234f46a35500c80a0cf52cb9eedf062b992666de..32ce287f80591789335a03a2e1dbeb67f66b1a98 100644
--- a/pkg/analyzer/lib/src/summary/resynthesize.dart
+++ b/pkg/analyzer/lib/src/summary/resynthesize.dart
@@ -594,7 +594,8 @@ class _ConstExprBuilder {
*/
TypeAnnotation _newTypeName() {
EntityRef typeRef = uc.references[refPtr++];
- DartType type = resynthesizer.buildType(context, typeRef);
+ DartType type =
+ resynthesizer.buildType(typeRef, context?.typeParameterContext);
return _buildTypeAst(type);
}
@@ -642,7 +643,7 @@ class _ConstExprBuilder {
return;
}
InterfaceType definingType = resynthesizer._createConstructorDefiningType(
- context, info, ref.typeArguments);
+ context?.typeParameterContext, info, ref.typeArguments);
constructorElement =
resynthesizer._getConstructorForInfo(definingType, info);
typeNode = _buildTypeAst(definingType);
@@ -1438,21 +1439,24 @@ class _ResynthesizerContext implements ResynthesizerContext {
@override
ConstructorElement resolveConstructorRef(
- ElementImpl context, EntityRef entry) {
- return _unitResynthesizer._getConstructorForEntry(context, entry);
+ TypeParameterizedElementMixin typeParameterContext, EntityRef entry) {
+ return _unitResynthesizer._getConstructorForEntry(
+ typeParameterContext, entry);
}
@override
- DartType resolveLinkedType(ElementImpl context, int slot) {
- return _unitResynthesizer.buildLinkedType(context, slot);
+ DartType resolveLinkedType(
+ int slot, TypeParameterizedElementMixin typeParameterContext) {
+ return _unitResynthesizer.buildLinkedType(slot, typeParameterContext);
}
@override
- DartType resolveTypeRef(ElementImpl context, EntityRef type,
+ DartType resolveTypeRef(
+ EntityRef type, TypeParameterizedElementMixin typeParameterContext,
{bool defaultVoid: false,
bool instantiateToBoundsAllowed: true,
bool declaredType: false}) {
- return _unitResynthesizer.buildType(context, type,
+ return _unitResynthesizer.buildType(type, typeParameterContext,
defaultVoid: defaultVoid,
instantiateToBoundsAllowed: instantiateToBoundsAllowed,
declaredType: declaredType);
@@ -1621,7 +1625,8 @@ class _UnitResynthesizer {
* Build the appropriate [DartType] object corresponding to a slot id in the
* [LinkedUnit.types] table.
*/
- DartType buildLinkedType(ElementImpl context, int slot) {
+ DartType buildLinkedType(
+ int slot, TypeParameterizedElementMixin typeParameterContext) {
if (slot == 0) {
// A slot id of 0 means there is no [DartType] object to build.
return null;
@@ -1632,7 +1637,7 @@ class _UnitResynthesizer {
// stored in this slot.
return null;
}
- return buildType(context, type);
+ return buildType(type, typeParameterContext);
}
/**
@@ -1641,7 +1646,8 @@ class _UnitResynthesizer {
* deserialized, so handles are used to avoid having to deserialize other
* libraries in the process.
*/
- DartType buildType(ElementImpl context, EntityRef type,
+ DartType buildType(
+ EntityRef type, TypeParameterizedElementMixin typeParameterContext,
{bool defaultVoid: false,
bool instantiateToBoundsAllowed: true,
bool declaredType: false}) {
@@ -1653,20 +1659,20 @@ class _UnitResynthesizer {
}
}
if (type.paramReference != 0) {
- return context.typeParameterContext
- .getTypeParameterType(type.paramReference);
+ return typeParameterContext.getTypeParameterType(type.paramReference);
} else if (type.entityKind == EntityRefKind.genericFunctionType) {
GenericFunctionTypeElement element =
- new GenericFunctionTypeElementImpl.forSerialized(context, type);
+ new GenericFunctionTypeElementImpl.forSerialized(
+ type, typeParameterContext);
return element.type;
} else if (type.syntheticReturnType != null) {
- FunctionElementImpl element = new FunctionElementImpl_forLUB(
- unit, context.typeParameterContext, type);
+ FunctionElementImpl element =
+ new FunctionElementImpl_forLUB(unit, typeParameterContext, type);
return element.type;
} else {
DartType getTypeArgument(int i) {
if (i < type.typeArguments.length) {
- return buildType(context, type.typeArguments[i],
+ return buildType(type.typeArguments[i], typeParameterContext,
declaredType: declaredType);
} else {
return DynamicTypeImpl.instance;
@@ -1923,15 +1929,18 @@ class _UnitResynthesizer {
* [typeArgumentRefs] to the given linked [info]. Return [DynamicTypeImpl]
* if the [info] is unresolved.
*/
- DartType _createConstructorDefiningType(ElementImpl context,
- _ReferenceInfo info, List<EntityRef> typeArgumentRefs) {
+ DartType _createConstructorDefiningType(
+ TypeParameterizedElementMixin typeParameterContext,
+ _ReferenceInfo info,
+ List<EntityRef> typeArgumentRefs) {
bool isClass = info.element is ClassElement;
_ReferenceInfo classInfo = isClass ? info : info.enclosing;
if (classInfo == null) {
return DynamicTypeImpl.instance;
}
- List<DartType> typeArguments =
- typeArgumentRefs.map((t) => buildType(context, t)).toList();
+ List<DartType> typeArguments = typeArgumentRefs
+ .map((t) => buildType(t, typeParameterContext))
+ .toList();
return classInfo.buildType(true, typeArguments.length, (i) {
if (i < typeArguments.length) {
return typeArguments[i];
@@ -1945,10 +1954,10 @@ class _UnitResynthesizer {
* Return the [ConstructorElement] corresponding to the given [entry].
*/
ConstructorElement _getConstructorForEntry(
- ElementImpl context, EntityRef entry) {
+ TypeParameterizedElementMixin typeParameterContext, EntityRef entry) {
_ReferenceInfo info = getReferenceInfo(entry.reference);
- DartType type =
- _createConstructorDefiningType(context, info, entry.typeArguments);
+ DartType type = _createConstructorDefiningType(
+ typeParameterContext, info, entry.typeArguments);
if (type is InterfaceType) {
return _getConstructorForInfo(type, info);
}
« no previous file with comments | « pkg/analyzer/lib/src/summary/link.dart ('k') | pkg/analyzer/test/src/summary/resynthesize_common.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698