@Override
 public String visitTypeVar(TypeVar t, Locale locale) {
   if (unique(t) || !getConfiguration().isEnabled(RichFormatterFeature.UNIQUE_TYPEVAR_NAMES)) {
     return t.toString();
   } else {
     return localize(
         locale, "compiler.misc.type.var", t.toString(), indexOf(t, WhereClauseKind.TYPEVAR));
   }
 }
 private boolean unique(TypeVar typevar) {
   int found = 0;
   for (Type t : whereClauses.get(WhereClauseKind.TYPEVAR).keySet()) {
     if (t.toString().equals(typevar.toString())) {
       found++;
     }
   }
   if (found < 1) throw new AssertionError("Missing type variable in where clause " + typevar);
   return found == 1;
 }
Пример #3
0
 public Void visitTypeVar(TypeVar type, Void ignore) {
   // For TypeVars (and not subtypes), the bound should always be
   // null or bot. So, only print the bound for subtypes of TypeVar,
   // or if the bound is (erroneously) not null or bot.
   if (!type.hasTag(TypeTag.TYPEVAR)
       || !(type.bound == null || type.bound.hasTag(TypeTag.BOT))) {
     printType("bound", type.bound, Details.FULL);
   }
   printType("lower", type.lower, Details.FULL);
   return visitType(type, null);
 }