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

Side by Side Diff: pkg/analyzer/lib/src/summary/summarize_elements.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 serialization.elements; 5 library serialization.elements;
6 6
7 import 'package:analyzer/dart/element/element.dart'; 7 import 'package:analyzer/dart/element/element.dart';
8 import 'package:analyzer/dart/element/type.dart'; 8 import 'package:analyzer/dart/element/type.dart';
9 import 'package:analyzer/src/dart/element/element.dart'; 9 import 'package:analyzer/src/dart/element/element.dart';
10 import 'package:analyzer/src/dart/element/type.dart'; 10 import 'package:analyzer/src/dart/element/type.dart';
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 } 433 }
434 434
435 /** 435 /**
436 * Serialize the given [executableElement], creating an [UnlinkedExecutable]. 436 * Serialize the given [executableElement], creating an [UnlinkedExecutable].
437 */ 437 */
438 UnlinkedExecutableBuilder serializeExecutable( 438 UnlinkedExecutableBuilder serializeExecutable(
439 ExecutableElement executableElement) { 439 ExecutableElement executableElement) {
440 UnlinkedExecutableBuilder b = new UnlinkedExecutableBuilder(); 440 UnlinkedExecutableBuilder b = new UnlinkedExecutableBuilder();
441 b.name = executableElement.name; 441 b.name = executableElement.name;
442 b.nameOffset = executableElement.nameOffset; 442 b.nameOffset = executableElement.nameOffset;
443 if (executableElement is! ConstructorElement) { 443 if (executableElement is! ConstructorElement &&
444 if (executableElement.hasImplicitReturnType) { 444 !executableElement.hasImplicitReturnType) {
445 // In strong mode, the variable's static type may have been overwritten 445 b.returnType = serializeTypeRef(
446 // by an inferred type. In this part of the summary we want to store 446 executableElement.type.returnType, executableElement);
447 // the weak mode static type (which is `dynamic`), since the strong
448 // mode static type is fully linked information.
449 b.returnType = serializeTypeRef(
450 librarySerializer.typeProvider.dynamicType, executableElement);
451 } else {
452 b.returnType = serializeTypeRef(
453 executableElement.type.returnType, executableElement);
454 }
455 } 447 }
456 b.typeParameters = 448 b.typeParameters =
457 executableElement.typeParameters.map(serializeTypeParam).toList(); 449 executableElement.typeParameters.map(serializeTypeParam).toList();
458 b.parameters = 450 b.parameters =
459 executableElement.type.parameters.map(serializeParam).toList(); 451 executableElement.type.parameters.map(serializeParam).toList();
460 if (executableElement is PropertyAccessorElement) { 452 if (executableElement is PropertyAccessorElement) {
461 if (executableElement.isGetter) { 453 if (executableElement.isGetter) {
462 b.kind = UnlinkedExecutableKind.getter; 454 b.kind = UnlinkedExecutableKind.getter;
463 } else { 455 } else {
464 b.kind = UnlinkedExecutableKind.setter; 456 b.kind = UnlinkedExecutableKind.setter;
465 } 457 }
466 } else if (executableElement is ConstructorElement) { 458 } else if (executableElement is ConstructorElement) {
467 b.kind = UnlinkedExecutableKind.constructor; 459 b.kind = UnlinkedExecutableKind.constructor;
468 b.isConst = executableElement.isConst; 460 b.isConst = executableElement.isConst;
469 b.isFactory = executableElement.isFactory; 461 b.isFactory = executableElement.isFactory;
470 } else { 462 } else {
471 b.kind = UnlinkedExecutableKind.functionOrMethod; 463 b.kind = UnlinkedExecutableKind.functionOrMethod;
472 } 464 }
473 b.isAbstract = executableElement.isAbstract; 465 b.isAbstract = executableElement.isAbstract;
474 b.isStatic = executableElement.isStatic && 466 b.isStatic = executableElement.isStatic &&
475 executableElement.enclosingElement is ClassElement; 467 executableElement.enclosingElement is ClassElement;
476 b.hasImplicitReturnType = executableElement.hasImplicitReturnType;
477 b.isExternal = executableElement.isExternal; 468 b.isExternal = executableElement.isExternal;
478 b.documentationComment = serializeDocumentation(executableElement); 469 b.documentationComment = serializeDocumentation(executableElement);
479 return b; 470 return b;
480 } 471 }
481 472
482 /** 473 /**
483 * Serialize the given [exportElement] into an [UnlinkedExportNonPublic]. 474 * Serialize the given [exportElement] into an [UnlinkedExportNonPublic].
484 */ 475 */
485 UnlinkedExportNonPublicBuilder serializeExportNonPublic( 476 UnlinkedExportNonPublicBuilder serializeExportNonPublic(
486 ExportElement exportElement) { 477 ExportElement exportElement) {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
540 break; 531 break;
541 case ParameterKind.POSITIONAL: 532 case ParameterKind.POSITIONAL:
542 b.kind = UnlinkedParamKind.positional; 533 b.kind = UnlinkedParamKind.positional;
543 break; 534 break;
544 case ParameterKind.NAMED: 535 case ParameterKind.NAMED:
545 b.kind = UnlinkedParamKind.named; 536 b.kind = UnlinkedParamKind.named;
546 break; 537 break;
547 } 538 }
548 b.isInitializingFormal = parameter.isInitializingFormal; 539 b.isInitializingFormal = parameter.isInitializingFormal;
549 DartType type = parameter.type; 540 DartType type = parameter.type;
550 if (parameter.isInitializingFormal && parameter.hasImplicitType) { 541 if (!parameter.hasImplicitType) {
551 b.hasImplicitType = true;
552 // We don't store the type of initializing formals that have an implicit
553 // type, because the type is inherited from the field.
554 } else {
555 if (type is FunctionType) { 542 if (type is FunctionType) {
556 b.isFunctionTyped = true; 543 b.isFunctionTyped = true;
557 b.type = serializeTypeRef(type.returnType, parameter); 544 b.type = serializeTypeRef(type.returnType, parameter);
558 b.parameters = type.parameters 545 b.parameters = type.parameters
559 .map((parameter) => serializeParam(parameter, context)) 546 .map((parameter) => serializeParam(parameter, context))
560 .toList(); 547 .toList();
561 } else { 548 } else {
562 b.type = serializeTypeRef(type, context); 549 b.type = serializeTypeRef(type, context);
563 b.hasImplicitType = parameter.hasImplicitType;
564 } 550 }
565 } 551 }
566 return b; 552 return b;
567 } 553 }
568 554
569 /** 555 /**
570 * Serialize the given [prefix] into an index into the references table. 556 * Serialize the given [prefix] into an index into the references table.
571 */ 557 */
572 int serializePrefix(PrefixElement element) { 558 int serializePrefix(PrefixElement element) {
573 return referenceMap.putIfAbsent(element, () { 559 return referenceMap.putIfAbsent(element, () {
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
689 return unresolvedReferenceIndex; 675 return unresolvedReferenceIndex;
690 } 676 }
691 677
692 /** 678 /**
693 * Serialize the given [variable], creating an [UnlinkedVariable]. 679 * Serialize the given [variable], creating an [UnlinkedVariable].
694 */ 680 */
695 UnlinkedVariableBuilder serializeVariable(PropertyInducingElement variable) { 681 UnlinkedVariableBuilder serializeVariable(PropertyInducingElement variable) {
696 UnlinkedVariableBuilder b = new UnlinkedVariableBuilder(); 682 UnlinkedVariableBuilder b = new UnlinkedVariableBuilder();
697 b.name = variable.name; 683 b.name = variable.name;
698 b.nameOffset = variable.nameOffset; 684 b.nameOffset = variable.nameOffset;
699 if (variable.hasImplicitType) { 685 if (!variable.hasImplicitType) {
700 // In strong mode, the variable's static type may have been overwritten
701 // by an inferred type. In this part of the summary we want to store the
702 // weak mode static type (which is `dynamic`), since the strong mode
703 // static type is fully linked information.
704 b.type = serializeTypeRef(
705 librarySerializer.typeProvider.dynamicType, variable);
706 } else {
707 b.type = serializeTypeRef(variable.type, variable); 686 b.type = serializeTypeRef(variable.type, variable);
708 } 687 }
709 b.isStatic = variable.isStatic && variable.enclosingElement is ClassElement; 688 b.isStatic = variable.isStatic && variable.enclosingElement is ClassElement;
710 b.isFinal = variable.isFinal; 689 b.isFinal = variable.isFinal;
711 b.isConst = variable.isConst; 690 b.isConst = variable.isConst;
712 b.hasImplicitType = variable.hasImplicitType;
713 b.documentationComment = serializeDocumentation(variable); 691 b.documentationComment = serializeDocumentation(variable);
714 if (variable.isConst && variable is ConstVariableElement) { 692 if (variable.isConst && variable is ConstVariableElement) {
715 ConstVariableElement constVariable = variable as ConstVariableElement; 693 ConstVariableElement constVariable = variable as ConstVariableElement;
716 Expression initializer = constVariable.constantInitializer; 694 Expression initializer = constVariable.constantInitializer;
717 if (initializer != null) { 695 if (initializer != null) {
718 b.constExpr = serializeConstExpr(initializer); 696 b.constExpr = serializeConstExpr(initializer);
719 } 697 }
720 } 698 }
721 if (b.isFinal || b.isConst) { 699 if (b.isFinal || b.isConst) {
722 b.propagatedTypeSlot = storeLinkedType(variable.propagatedType, variable); 700 b.propagatedTypeSlot = storeLinkedType(variable.propagatedType, variable);
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
995 exportNames.add(new LinkedExportNameBuilder( 973 exportNames.add(new LinkedExportNameBuilder(
996 name: name, 974 name: name,
997 dependency: serializeDependency(dependentLibrary), 975 dependency: serializeDependency(dependentLibrary),
998 unit: unit, 976 unit: unit,
999 kind: kind)); 977 kind: kind));
1000 } 978 }
1001 pb.exportNames = exportNames; 979 pb.exportNames = exportNames;
1002 return pb; 980 return pb;
1003 } 981 }
1004 } 982 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698