langtools/src/share/classes/com/sun/tools/javac/code/Types.java
changeset 1993 9b37ef07ba64
parent 1992 7be5dee022d5
child 2218 a8ec0baae870
child 2212 1d3dc0e0ba0c
equal deleted inserted replaced
1992:7be5dee022d5 1993:9b37ef07ba64
  2129     public List<Type> substBounds(List<Type> tvars,
  2129     public List<Type> substBounds(List<Type> tvars,
  2130                                   List<Type> from,
  2130                                   List<Type> from,
  2131                                   List<Type> to) {
  2131                                   List<Type> to) {
  2132         if (tvars.isEmpty())
  2132         if (tvars.isEmpty())
  2133             return tvars;
  2133             return tvars;
  2134         if (tvars.tail.isEmpty())
       
  2135             // fast common case
       
  2136             return List.<Type>of(substBound((TypeVar)tvars.head, from, to));
       
  2137         ListBuffer<Type> newBoundsBuf = lb();
  2134         ListBuffer<Type> newBoundsBuf = lb();
  2138         boolean changed = false;
  2135         boolean changed = false;
  2139         // calculate new bounds
  2136         // calculate new bounds
  2140         for (Type t : tvars) {
  2137         for (Type t : tvars) {
  2141             TypeVar tv = (TypeVar) t;
  2138             TypeVar tv = (TypeVar) t;
  2171 
  2168 
  2172     public TypeVar substBound(TypeVar t, List<Type> from, List<Type> to) {
  2169     public TypeVar substBound(TypeVar t, List<Type> from, List<Type> to) {
  2173         Type bound1 = subst(t.bound, from, to);
  2170         Type bound1 = subst(t.bound, from, to);
  2174         if (bound1 == t.bound)
  2171         if (bound1 == t.bound)
  2175             return t;
  2172             return t;
  2176         else
  2173         else {
  2177             return new TypeVar(t.tsym, bound1, syms.botType);
  2174             // create new type variable without bounds
       
  2175             TypeVar tv = new TypeVar(t.tsym, null, syms.botType);
       
  2176             // the new bound should use the new type variable in place
       
  2177             // of the old
       
  2178             tv.bound = subst(bound1, List.<Type>of(t), List.<Type>of(tv));
       
  2179             return tv;
       
  2180         }
  2178     }
  2181     }
  2179     // </editor-fold>
  2182     // </editor-fold>
  2180 
  2183 
  2181     // <editor-fold defaultstate="collapsed" desc="hasSameBounds">
  2184     // <editor-fold defaultstate="collapsed" desc="hasSameBounds">
  2182     /**
  2185     /**