private int indexOf(Type type, WhereClauseKind kind) {
   int index = 1;
   for (Type t : whereClauses.get(kind).keySet()) {
     if (t.tsym == type.tsym) {
       return index;
     }
     if (kind != WhereClauseKind.TYPEVAR || t.toString().equals(type.toString())) {
       index++;
     }
   }
   return -1;
 }
Ejemplo n.º 2
0
 public WildcardType getWildcardType(TypeMirror extendsBound, TypeMirror superBound) {
   BoundKind bkind;
   Type bound;
   if (extendsBound == null && superBound == null) {
     bkind = BoundKind.UNBOUND;
     bound = syms.objectType;
   } else if (superBound == null) {
     bkind = BoundKind.EXTENDS;
     bound = (Type) extendsBound;
   } else if (extendsBound == null) {
     bkind = BoundKind.SUPER;
     bound = (Type) superBound;
   } else {
     throw new IllegalArgumentException("Extends and super bounds cannot both be provided");
   }
   switch (bound.getKind()) {
     case ARRAY:
     case DECLARED:
     case ERROR:
     case TYPEVAR:
       return new Type.WildcardType(bound, bkind, syms.boundClass);
     default:
       throw new IllegalArgumentException(bound.toString());
   }
 }
 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;
 }