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

Unified Diff: pkg/analyzer/lib/src/dart/element/type.dart

Issue 2762743002: Include type arguments for non-synthetic FunctionTypeImpl(s) into displayName. (Closed)
Patch Set: Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/analyzer/test/src/summary/resynthesize_common.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/dart/element/type.dart
diff --git a/pkg/analyzer/lib/src/dart/element/type.dart b/pkg/analyzer/lib/src/dart/element/type.dart
index 1cfdbf8d15b30aee62cbbe56cb56e53a8437e83d..adb40bd96769adb4c784052628953aa5cf79bde9 100644
--- a/pkg/analyzer/lib/src/dart/element/type.dart
+++ b/pkg/analyzer/lib/src/dart/element/type.dart
@@ -454,13 +454,41 @@ class FunctionTypeImpl extends TypeImpl implements FunctionType {
@override
String get displayName {
String name = this.name;
+
+ // Function types have an empty name when they are defined implicitly by
+ // either a closure or as part of a parameter declaration.
if (name == null || name.length == 0) {
- // Function types have an empty name when they are defined implicitly by
- // either a closure or as part of a parameter declaration.
StringBuffer buffer = new StringBuffer();
appendTo(buffer, new Set.identity());
+ return buffer.toString();
+ }
+
+ List<DartType> typeArguments = this.typeArguments;
+
+ bool allDynamic = true;
Brian Wilkerson 2017/03/20 20:13:47 Just an idea: this block of code would make a nice
+ for (DartType type in typeArguments) {
+ if (type != null && !type.isDynamic) {
+ allDynamic = false;
+ break;
+ }
+ }
+
+ // If there is at least one non-dynamic type, then list them out.
+ if (!allDynamic) {
+ StringBuffer buffer = new StringBuffer();
+ buffer.write(name);
+ buffer.write("<");
+ for (int i = 0; i < typeArguments.length; i++) {
+ if (i != 0) {
+ buffer.write(", ");
+ }
+ DartType typeArg = typeArguments[i];
+ buffer.write(typeArg.displayName);
+ }
+ buffer.write(">");
name = buffer.toString();
}
+
return name;
}
« no previous file with comments | « no previous file | pkg/analyzer/test/src/summary/resynthesize_common.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698