| Index: pkg/analyzer/tool/summary/dump_inferred_types.dart
|
| diff --git a/pkg/analyzer/tool/summary/dump_inferred_types.dart b/pkg/analyzer/tool/summary/dump_inferred_types.dart
|
| index 3f5ce3251ee5d4a0536de7510921898f150bdc08..0668513ac1c63070a2835cea78b1cb360b0e209f 100644
|
| --- a/pkg/analyzer/tool/summary/dump_inferred_types.dart
|
| +++ b/pkg/analyzer/tool/summary/dump_inferred_types.dart
|
| @@ -80,6 +80,29 @@ class InferredTypeCollector {
|
| }
|
|
|
| /**
|
| + * Interpret the given [param] as a parameter in a synthetic typedef, and
|
| + * format it as a string.
|
| + */
|
| + String formatParam(UnlinkedParam param) {
|
| + if (param.isFunctionTyped) {
|
| + // TODO(paulberry): fix this case.
|
| + return 'BAD(${JSON.encode(param)})';
|
| + }
|
| + String result;
|
| + if (param.type != null) {
|
| + result = '${formatType(param.type)} ${param.name}';
|
| + } else {
|
| + result = param.name;
|
| + }
|
| + if (param.kind == UnlinkedParamKind.named) {
|
| + result = '{$result}';
|
| + } else if (param.kind == UnlinkedParamKind.positional) {
|
| + result = '[$result]';
|
| + }
|
| + return result;
|
| + }
|
| +
|
| + /**
|
| * Convert the reference with index [index] into a string. If [typeOf] is
|
| * `true`, the reference is being used in the context of naming a type, so
|
| * if the entity being referenced is not a type, it will be enclosed in
|
| @@ -92,6 +115,10 @@ class InferredTypeCollector {
|
| case ReferenceKind.function:
|
| case ReferenceKind.propertyAccessor:
|
| case ReferenceKind.topLevelFunction:
|
| + case ReferenceKind.method:
|
| + case ReferenceKind.typedef:
|
| + case ReferenceKind.prefix:
|
| + case ReferenceKind.topLevelPropertyAccessor:
|
| break;
|
| default:
|
| // TODO(paulberry): fix this case.
|
| @@ -116,7 +143,9 @@ class InferredTypeCollector {
|
| assert(name.isEmpty);
|
| result += 'localFunction[${linkedRef.localIndex}]';
|
| }
|
| - if (!typeOf || linkedRef.kind == ReferenceKind.classOrEnum) {
|
| + if (!typeOf ||
|
| + linkedRef.kind == ReferenceKind.classOrEnum ||
|
| + linkedRef.kind == ReferenceKind.typedef) {
|
| return result;
|
| } else {
|
| return 'typeof($result)';
|
| @@ -128,11 +157,12 @@ class InferredTypeCollector {
|
| * a string.
|
| */
|
| String formatType(EntityRef entityRef) {
|
| - if (entityRef.implicitFunctionTypeIndices.isNotEmpty ||
|
| - entityRef.syntheticParams.isNotEmpty ||
|
| - entityRef.syntheticReturnType != null) {
|
| - // TODO(paulberry): fix these cases.
|
| - return 'BAD(${JSON.encode(entityRef.toJson())})';
|
| + List<int> implicitFunctionTypeIndices =
|
| + entityRef.implicitFunctionTypeIndices;
|
| + if (entityRef.syntheticReturnType != null) {
|
| + String params = entityRef.syntheticParams.map(formatParam).join(', ');
|
| + String retType = formatType(entityRef.syntheticReturnType);
|
| + return '($params) -> $retType';
|
| }
|
| if (entityRef.paramReference != 0) {
|
| return typeParamsInScope[
|
| @@ -142,6 +172,10 @@ class InferredTypeCollector {
|
| if (entityRef.typeArguments.isNotEmpty) {
|
| result += '<${entityRef.typeArguments.map(formatType).join(', ')}>';
|
| }
|
| + if (implicitFunctionTypeIndices.isNotEmpty) {
|
| + result =
|
| + 'parameterOf($result, ${implicitFunctionTypeIndices.join(', ')})';
|
| + }
|
| return result;
|
| }
|
|
|
|
|