src/share/classes/com/sun/tools/javac/code/Type.java

changeset 2047
5f915a0c9615
parent 1955
ec77c7b46c37
child 2050
09301757bb32
equal deleted inserted replaced
2046:1fe358ea75ff 2047:5f915a0c9615
431 if (t.containsAny(ts2)) return true; 431 if (t.containsAny(ts2)) return true;
432 return false; 432 return false;
433 } 433 }
434 434
435 public static List<Type> filter(List<Type> ts, Filter<Type> tf) { 435 public static List<Type> filter(List<Type> ts, Filter<Type> tf) {
436 ListBuffer<Type> buf = ListBuffer.lb(); 436 ListBuffer<Type> buf = new ListBuffer<>();
437 for (Type t : ts) { 437 for (Type t : ts) {
438 if (tf.accepts(t)) { 438 if (tf.accepts(t)) {
439 buf.append(t); 439 buf.append(t);
440 } 440 }
441 } 441 }
1494 else return this; 1494 else return this;
1495 } 1495 }
1496 1496
1497 /** get all bounds of a given kind */ 1497 /** get all bounds of a given kind */
1498 public List<Type> getBounds(InferenceBound... ibs) { 1498 public List<Type> getBounds(InferenceBound... ibs) {
1499 ListBuffer<Type> buf = ListBuffer.lb(); 1499 ListBuffer<Type> buf = new ListBuffer<>();
1500 for (InferenceBound ib : ibs) { 1500 for (InferenceBound ib : ibs) {
1501 buf.appendList(bounds.get(ib)); 1501 buf.appendList(bounds.get(ib));
1502 } 1502 }
1503 return buf.toList(); 1503 return buf.toList();
1504 } 1504 }
1505 1505
1506 /** get the list of declared (upper) bounds */ 1506 /** get the list of declared (upper) bounds */
1507 public List<Type> getDeclaredBounds() { 1507 public List<Type> getDeclaredBounds() {
1508 ListBuffer<Type> buf = ListBuffer.lb(); 1508 ListBuffer<Type> buf = new ListBuffer<>();
1509 int count = 0; 1509 int count = 0;
1510 for (Type b : getBounds(InferenceBound.UPPER)) { 1510 for (Type b : getBounds(InferenceBound.UPPER)) {
1511 if (count++ == declaredCount) break; 1511 if (count++ == declaredCount) break;
1512 buf.append(b); 1512 buf.append(b);
1513 } 1513 }
1563 } 1563 }
1564 }; 1564 };
1565 for (Map.Entry<InferenceBound, List<Type>> _entry : bounds.entrySet()) { 1565 for (Map.Entry<InferenceBound, List<Type>> _entry : bounds.entrySet()) {
1566 InferenceBound ib = _entry.getKey(); 1566 InferenceBound ib = _entry.getKey();
1567 List<Type> prevBounds = _entry.getValue(); 1567 List<Type> prevBounds = _entry.getValue();
1568 ListBuffer<Type> newBounds = ListBuffer.lb(); 1568 ListBuffer<Type> newBounds = new ListBuffer<>();
1569 ListBuffer<Type> deps = ListBuffer.lb(); 1569 ListBuffer<Type> deps = new ListBuffer<>();
1570 //step 1 - re-add bounds that are not dependent on ivars 1570 //step 1 - re-add bounds that are not dependent on ivars
1571 for (Type t : prevBounds) { 1571 for (Type t : prevBounds) {
1572 if (!t.containsAny(instVars)) { 1572 if (!t.containsAny(instVars)) {
1573 newBounds.append(t); 1573 newBounds.append(t);
1574 } else { 1574 } else {

mercurial