Chromium Code Reviews| 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 6e9e8b58de96b75255654888ef5fa1fcc8b14ddc..4eeb3d5cd4ca839edfa01e6a4a153d87e4be0b24 100644 |
| --- a/pkg/analyzer/lib/src/summary/resynthesize.dart |
| +++ b/pkg/analyzer/lib/src/summary/resynthesize.dart |
| @@ -411,6 +411,16 @@ class _ConstExprBuilder { |
| _pushMap(AstFactory.typeArgumentList(<TypeName>[keyType, valueType])); |
| break; |
| case UnlinkedConstOperation.pushReference: |
| + EntityRef ref = uc.references[refPtr++]; |
| + _ReferenceInfo info = resynthesizer.referenceInfos[ref.reference]; |
| + if (info.type != null) { |
| + Identifier node = _buildTypeIdentifierAst(info.type); |
| + _push(node); |
| + } else { |
| + throw new StateError( |
| + 'Unsupported reference ${info.element?.runtimeType}'); |
| + } |
| + break; |
| case UnlinkedConstOperation.invokeConstructor: |
| case UnlinkedConstOperation.length: |
| return AstFactory.nullLiteral(); |
| @@ -437,6 +447,13 @@ class _ConstExprBuilder { |
| throw new StateError('Unsupported type $type'); |
| } |
| + Identifier _buildTypeIdentifierAst(DartType type) { |
| + String name = type.name; |
| + SimpleIdentifier node = AstFactory.identifier3(name); |
| + node.staticElement = type.element; |
| + return node; |
| + } |
| + |
| InterpolationElement _newInterpolationElement(Expression expr) { |
| if (expr is SimpleStringLiteral) { |
| return new InterpolationString(expr.literal, expr.value); |
| @@ -1270,7 +1287,7 @@ class _LibraryResynthesizer { |
| currentTypeParameters.length - type.paramReference] |
| .type; |
| } else { |
| - DartType getTypeParameter(int i) { |
| + DartType getTypeArgument(int i) { |
| if (i < type.typeArguments.length) { |
| return buildType(type.typeArguments[i]); |
| } else { |
| @@ -1279,7 +1296,7 @@ class _LibraryResynthesizer { |
| } |
| _ReferenceInfo referenceInfo = referenceInfos[type.reference]; |
| return referenceInfo.buildType( |
| - getTypeParameter, type.implicitFunctionTypeIndices); |
| + getTypeArgument, type.implicitFunctionTypeIndices); |
| } |
| } |
| @@ -1591,8 +1608,8 @@ class _ReferenceInfo { |
| /** |
| * Create a new [_ReferenceInfo] object referring to an element called [name] |
| - * via the element handle [elementHandle], and having [numTypeParameters] |
| - * type parameters. |
| + * via the element handle [element], and having [numTypeParameters] type |
| + * parameters. |
| * |
| * For the special types `dynamic` and `void`, [specialType] should point to |
| * the type itself. Otherwise, pass `null` and the type will be computed |
| @@ -1602,9 +1619,7 @@ class _ReferenceInfo { |
| this.name, this.element, DartType specialType, this.numTypeParameters) { |
| if (specialType != null) { |
| type = specialType; |
| - } else if (numTypeParameters == 0) { |
| - // We can precompute the type because it doesn't depend on type |
| - // parameters. |
| + } else { |
| type = _buildType(null, null); |
| } |
| } |
| @@ -1638,8 +1653,8 @@ class _ReferenceInfo { |
| /** |
| * If this reference refers to a type, build a [DartType] which instantiates |
| - * it with type arguments returned by [getTypeArgument]. Otherwise return |
| - * `null`. |
| + * it with type arguments returned by [getTypeArgument] or with all `dynamic` |
| + * type arguments if [getTypeArgument] is `null`. Otherwise return `null`. |
| * |
| * If [implicitFunctionTypeIndices] is not null, a [DartType] should be |
| * created which refers to a function type implicitly defined by one of the |
| @@ -1652,7 +1667,10 @@ class _ReferenceInfo { |
| if (numTypeParameters != 0) { |
| typeArguments = <DartType>[]; |
| for (int i = 0; i < numTypeParameters; i++) { |
| - typeArguments.add(getTypeArgument(i)); |
| + DartType typeArgument = getTypeArgument != null |
|
Paul Berry
2016/02/01 16:11:40
Nit: Rather than make this change (which will burd
scheglov
2016/02/01 17:22:25
Done.
|
| + ? getTypeArgument(i) |
| + : DynamicTypeImpl.instance; |
| + typeArguments.add(typeArgument); |
| } |
| } |
| ElementHandle element = this.element; // To allow type promotion |