[analysis_server] Add nullability assertions to token list API

Easy way to not have to support it today, but not have to worry about it
being buggy in the future.

Change-Id: I4f60bcf459c770614faf566b670744ab59c1a7ea
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/163125
Auto-Submit: Mike Fairhurst <mfairhurst@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
diff --git a/pkg/analysis_server/lib/src/services/completion/token_details/token_detail_builder.dart b/pkg/analysis_server/lib/src/services/completion/token_details/token_detail_builder.dart
index 8316e43..3be9cd3 100644
--- a/pkg/analysis_server/lib/src/services/completion/token_details/token_detail_builder.dart
+++ b/pkg/analysis_server/lib/src/services/completion/token_details/token_detail_builder.dart
@@ -115,6 +115,8 @@
     } else if (type is InterfaceType) {
       Element element = type.element;
       if (element == null || element.isSynthetic) {
+        assert(false, "untested branch may print nullable types wrong");
+        // TODO: test this, use the the library's nullability (not tracked yet).
         buffer.write(type.getDisplayString(withNullability: false));
       } else {
 //        String uri = element.library.source.uri.toString();
@@ -132,7 +134,9 @@
         }
       }
     } else {
-      // Handle `void` and `dynamic`.
+      // Handle `void` and `dynamic`. Nullability doesn't affect this.
+      assert(type.getDisplayString(withNullability: false) ==
+          type.getDisplayString(withNullability: true));
       buffer.write(type.getDisplayString(withNullability: false));
     }
   }