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

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

Issue 1602263002: Fix summarization of trailing `dynamic` type arguments. (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/type.dart'; 9 import 'package:analyzer/src/dart/element/type.dart';
10 import 'package:analyzer/src/generated/resolver.dart'; 10 import 'package:analyzer/src/generated/resolver.dart';
(...skipping 715 matching lines...) Expand 10 before | Expand all | Expand 10 after
726 numTypeParameters: numTypeParameters)); 726 numTypeParameters: numTypeParameters));
727 return index; 727 return index;
728 }); 728 });
729 } 729 }
730 List<DartType> typeArguments; 730 List<DartType> typeArguments;
731 if (type is InterfaceType) { 731 if (type is InterfaceType) {
732 typeArguments = type.typeArguments; 732 typeArguments = type.typeArguments;
733 } else if (type is FunctionType) { 733 } else if (type is FunctionType) {
734 typeArguments = type.typeArguments; 734 typeArguments = type.typeArguments;
735 } 735 }
736 if (typeArguments != null && 736 if (typeArguments != null) {
737 typeArguments.any((DartType argument) => !argument.isDynamic)) { 737 // Trailing type arguments of type 'dynamic' should be omitted.
738 b.typeArguments = typeArguments 738 int numArgsToSerialize = typeArguments.length;
739 .map((DartType t) => serializeTypeRef(t, context)) 739 while (numArgsToSerialize > 0 &&
740 .toList(); 740 typeArguments[numArgsToSerialize - 1].isDynamic) {
741 --numArgsToSerialize;
742 }
743 if (numArgsToSerialize > 0) {
744 List<UnlinkedTypeRefBuilder> serializedArguments =
745 <UnlinkedTypeRefBuilder>[];
746 for (int i = 0; i < numArgsToSerialize; i++) {
747 serializedArguments
748 .add(serializeTypeRef(typeArguments[i], context));
749 }
750 b.typeArguments = serializedArguments;
751 }
741 } 752 }
742 } 753 }
743 return b; 754 return b;
744 } 755 }
745 756
746 /** 757 /**
747 * Return the index of the entry in the references table 758 * Return the index of the entry in the references table
748 * ([UnlinkedLibrary.references] and [LinkedLibrary.references]) used for 759 * ([UnlinkedLibrary.references] and [LinkedLibrary.references]) used for
749 * unresolved references. A new entry is added to the table if necessary to 760 * unresolved references. A new entry is added to the table if necessary to
750 * satisfy the request. 761 * satisfy the request.
(...skipping 23 matching lines...) Expand all
774 b.nameOffset = variable.nameOffset; 785 b.nameOffset = variable.nameOffset;
775 b.type = serializeTypeRef(variable.type, variable); 786 b.type = serializeTypeRef(variable.type, variable);
776 b.isStatic = variable.isStatic && variable.enclosingElement is ClassElement; 787 b.isStatic = variable.isStatic && variable.enclosingElement is ClassElement;
777 b.isFinal = variable.isFinal; 788 b.isFinal = variable.isFinal;
778 b.isConst = variable.isConst; 789 b.isConst = variable.isConst;
779 b.hasImplicitType = variable.hasImplicitType; 790 b.hasImplicitType = variable.hasImplicitType;
780 b.documentationComment = serializeDocumentation(variable); 791 b.documentationComment = serializeDocumentation(variable);
781 return b; 792 return b;
782 } 793 }
783 } 794 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/summary/summarize_ast.dart ('k') | pkg/analyzer/test/src/summary/resynthesize_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698