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

Side by Side Diff: pkg/analyzer/lib/src/summary/resynthesize.dart

Issue 1622673002: Drop implicit types from summaries. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library summary_resynthesizer; 5 library summary_resynthesizer;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 8
9 import 'package:analyzer/dart/element/element.dart'; 9 import 'package:analyzer/dart/element/element.dart';
10 import 'package:analyzer/dart/element/type.dart'; 10 import 'package:analyzer/dart/element/type.dart';
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 UnlinkedExecutable serializedExecutable) { 559 UnlinkedExecutable serializedExecutable) {
560 List<TypeParameterType> oldTypeArguments = currentTypeArguments; 560 List<TypeParameterType> oldTypeArguments = currentTypeArguments;
561 int oldTypeParametersLength = currentTypeParameters.length; 561 int oldTypeParametersLength = currentTypeParameters.length;
562 if (serializedExecutable.typeParameters.isNotEmpty) { 562 if (serializedExecutable.typeParameters.isNotEmpty) {
563 executableElement.typeParameters = 563 executableElement.typeParameters =
564 serializedExecutable.typeParameters.map(buildTypeParameter).toList(); 564 serializedExecutable.typeParameters.map(buildTypeParameter).toList();
565 currentTypeParameters.addAll(executableElement.typeParameters); 565 currentTypeParameters.addAll(executableElement.typeParameters);
566 } 566 }
567 executableElement.parameters = 567 executableElement.parameters =
568 serializedExecutable.parameters.map(buildParameter).toList(); 568 serializedExecutable.parameters.map(buildParameter).toList();
569 if (serializedExecutable.returnType != null) { 569 if (serializedExecutable.kind == UnlinkedExecutableKind.constructor) {
570 // Caller handles setting the return type.
571 assert(serializedExecutable.returnType == null);
572 } else {
570 executableElement.returnType = buildType(serializedExecutable.returnType); 573 executableElement.returnType = buildType(serializedExecutable.returnType);
571 } else { 574 executableElement.hasImplicitReturnType =
572 // Null return type should only be used for constructors. Caller will 575 serializedExecutable.returnType == null;
573 // handle setting the return type.
574 assert(serializedExecutable.kind == UnlinkedExecutableKind.constructor);
575 } 576 }
576 executableElement.type = new FunctionTypeImpl.elementWithNameAndArgs( 577 executableElement.type = new FunctionTypeImpl.elementWithNameAndArgs(
577 executableElement, null, oldTypeArguments, false); 578 executableElement, null, oldTypeArguments, false);
578 executableElement.hasImplicitReturnType =
579 serializedExecutable.hasImplicitReturnType;
580 executableElement.external = serializedExecutable.isExternal; 579 executableElement.external = serializedExecutable.isExternal;
581 currentTypeParameters.removeRange( 580 currentTypeParameters.removeRange(
582 oldTypeParametersLength, currentTypeParameters.length); 581 oldTypeParametersLength, currentTypeParameters.length);
583 buildDocumentation( 582 buildDocumentation(
584 executableElement, serializedExecutable.documentationComment); 583 executableElement, serializedExecutable.documentationComment);
585 } 584 }
586 585
587 /** 586 /**
588 * Resynthesize an [ExportElement], 587 * Resynthesize an [ExportElement],
589 */ 588 */
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
901 parameterTypeElement.synthetic = true; 900 parameterTypeElement.synthetic = true;
902 parameterElement.parameters = 901 parameterElement.parameters =
903 serializedParameter.parameters.map(buildParameter).toList(); 902 serializedParameter.parameters.map(buildParameter).toList();
904 parameterTypeElement.enclosingElement = parameterElement; 903 parameterTypeElement.enclosingElement = parameterElement;
905 parameterTypeElement.shareParameters(parameterElement.parameters); 904 parameterTypeElement.shareParameters(parameterElement.parameters);
906 parameterTypeElement.returnType = buildType(serializedParameter.type); 905 parameterTypeElement.returnType = buildType(serializedParameter.type);
907 parameterElement.type = new FunctionTypeImpl.elementWithNameAndArgs( 906 parameterElement.type = new FunctionTypeImpl.elementWithNameAndArgs(
908 parameterTypeElement, null, currentTypeArguments, false); 907 parameterTypeElement, null, currentTypeArguments, false);
909 } else { 908 } else {
910 if (serializedParameter.isInitializingFormal && 909 if (serializedParameter.isInitializingFormal &&
911 serializedParameter.hasImplicitType) { 910 serializedParameter.type == null) {
912 // The type is inherited from the matching field. 911 // The type is inherited from the matching field.
913 parameterElement.type = fields[serializedParameter.name]?.type ?? 912 parameterElement.type = fields[serializedParameter.name]?.type ??
914 summaryResynthesizer.typeProvider.dynamicType; 913 summaryResynthesizer.typeProvider.dynamicType;
915 } else { 914 } else {
916 parameterElement.type = buildType(serializedParameter.type); 915 parameterElement.type = buildType(serializedParameter.type);
917 } 916 }
918 parameterElement.hasImplicitType = serializedParameter.hasImplicitType; 917 parameterElement.hasImplicitType = serializedParameter.type == null;
919 } 918 }
920 switch (serializedParameter.kind) { 919 switch (serializedParameter.kind) {
921 case UnlinkedParamKind.named: 920 case UnlinkedParamKind.named:
922 parameterElement.parameterKind = ParameterKind.NAMED; 921 parameterElement.parameterKind = ParameterKind.NAMED;
923 break; 922 break;
924 case UnlinkedParamKind.positional: 923 case UnlinkedParamKind.positional:
925 parameterElement.parameterKind = ParameterKind.POSITIONAL; 924 parameterElement.parameterKind = ParameterKind.POSITIONAL;
926 break; 925 break;
927 case UnlinkedParamKind.required: 926 case UnlinkedParamKind.required:
928 parameterElement.parameterKind = ParameterKind.REQUIRED; 927 parameterElement.parameterKind = ParameterKind.REQUIRED;
(...skipping 20 matching lines...) Expand all
949 return partUnit; 948 return partUnit;
950 } 949 }
951 950
952 /** 951 /**
953 * Build a [DartType] object based on a [EntityRef]. This [DartType] 952 * Build a [DartType] object based on a [EntityRef]. This [DartType]
954 * may refer to elements in other libraries than the library being 953 * may refer to elements in other libraries than the library being
955 * deserialized, so handles are used to avoid having to deserialize other 954 * deserialized, so handles are used to avoid having to deserialize other
956 * libraries in the process. 955 * libraries in the process.
957 */ 956 */
958 DartType buildType(EntityRef type) { 957 DartType buildType(EntityRef type) {
958 if (type == null) {
959 return summaryResynthesizer.typeProvider.dynamicType;
960 }
959 if (type.paramReference != 0) { 961 if (type.paramReference != 0) {
960 // TODO(paulberry): make this work for generic methods. 962 // TODO(paulberry): make this work for generic methods.
961 return currentTypeParameters[ 963 return currentTypeParameters[
962 currentTypeParameters.length - type.paramReference].type; 964 currentTypeParameters.length - type.paramReference].type;
963 } else { 965 } else {
964 // TODO(paulberry): handle references to things other than classes (note: 966 // TODO(paulberry): handle references to things other than classes (note:
965 // this should only occur in the case of erroneous code). 967 // this should only occur in the case of erroneous code).
966 // TODO(paulberry): test reference to something inside a part. 968 // TODO(paulberry): test reference to something inside a part.
967 // TODO(paulberry): test reference to something inside a part of the 969 // TODO(paulberry): test reference to something inside a part of the
968 // current lib. 970 // current lib.
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
1103 } 1105 }
1104 1106
1105 /** 1107 /**
1106 * Handle the parts that are common to top level variables and fields. 1108 * Handle the parts that are common to top level variables and fields.
1107 */ 1109 */
1108 void buildVariableCommonParts(PropertyInducingElementImpl element, 1110 void buildVariableCommonParts(PropertyInducingElementImpl element,
1109 UnlinkedVariable serializedVariable) { 1111 UnlinkedVariable serializedVariable) {
1110 element.type = buildType(serializedVariable.type); 1112 element.type = buildType(serializedVariable.type);
1111 element.const3 = serializedVariable.isConst; 1113 element.const3 = serializedVariable.isConst;
1112 element.final2 = serializedVariable.isFinal; 1114 element.final2 = serializedVariable.isFinal;
1113 element.hasImplicitType = serializedVariable.hasImplicitType; 1115 element.hasImplicitType = serializedVariable.type == null;
1114 element.propagatedType = 1116 element.propagatedType =
1115 buildLinkedType(serializedVariable.propagatedTypeSlot); 1117 buildLinkedType(serializedVariable.propagatedTypeSlot);
1116 buildDocumentation(element, serializedVariable.documentationComment); 1118 buildDocumentation(element, serializedVariable.documentationComment);
1117 } 1119 }
1118 1120
1119 /** 1121 /**
1120 * Finish creating a [TypeParameterElement] by deserializing its bound. 1122 * Finish creating a [TypeParameterElement] by deserializing its bound.
1121 */ 1123 */
1122 void finishTypeParameter(UnlinkedTypeParam serializedTypeParameter, 1124 void finishTypeParameter(UnlinkedTypeParam serializedTypeParameter,
1123 TypeParameterElementImpl typeParameterElement) { 1125 TypeParameterElementImpl typeParameterElement) {
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
1200 for (PropertyAccessorElementImpl accessor in unit.accessors) { 1202 for (PropertyAccessorElementImpl accessor in unit.accessors) {
1201 elementMap[accessor.identifier] = accessor; 1203 elementMap[accessor.identifier] = accessor;
1202 } 1204 }
1203 resummarizedElements[absoluteUri] = elementMap; 1205 resummarizedElements[absoluteUri] = elementMap;
1204 unitHolder = null; 1206 unitHolder = null;
1205 linkedUnit = null; 1207 linkedUnit = null;
1206 unlinkedUnit = null; 1208 unlinkedUnit = null;
1207 linkedTypeMap = null; 1209 linkedTypeMap = null;
1208 } 1210 }
1209 } 1211 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698