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

changeset 1891
42b3c5e92461
parent 1889
b0386f0dc28e
child 1898
a204cf7aab7e
equal deleted inserted replaced
1890:bfbedbfc522a 1891:42b3c5e92461
1512 buf.append(b); 1512 buf.append(b);
1513 } 1513 }
1514 return buf.toList(); 1514 return buf.toList();
1515 } 1515 }
1516 1516
1517 /** internal method used to override an undetvar bounds */
1518 public void setBounds(InferenceBound ib, List<Type> newBounds) {
1519 bounds.put(ib, newBounds);
1520 }
1521
1517 /** add a bound of a given kind - this might trigger listener notification */ 1522 /** add a bound of a given kind - this might trigger listener notification */
1518 public void addBound(InferenceBound ib, Type bound, Types types) { 1523 public void addBound(InferenceBound ib, Type bound, Types types) {
1519 Type bound2 = toTypeVarMap.apply(bound); 1524 Type bound2 = boundMap.apply(bound);
1520 List<Type> prevBounds = bounds.get(ib); 1525 List<Type> prevBounds = bounds.get(ib);
1521 for (Type b : prevBounds) { 1526 for (Type b : prevBounds) {
1522 //check for redundancy - use strict version of isSameType on tvars 1527 //check for redundancy - use strict version of isSameType on tvars
1523 //(as the standard version will lead to false positives w.r.t. clones ivars) 1528 //(as the standard version will lead to false positives w.r.t. clones ivars)
1524 if (types.isSameType(b, bound2, true) || bound == qtype) return; 1529 if (types.isSameType(b, bound2, true) || bound == qtype) return;
1525 } 1530 }
1526 bounds.put(ib, prevBounds.prepend(bound2)); 1531 bounds.put(ib, prevBounds.prepend(bound2));
1527 notifyChange(EnumSet.of(ib)); 1532 notifyChange(EnumSet.of(ib));
1528 } 1533 }
1529 //where 1534 //where
1530 Type.Mapping toTypeVarMap = new Mapping("toTypeVarMap") { 1535 Type.Mapping boundMap = new Mapping("boundMap") {
1531 @Override 1536 @Override
1532 public Type apply(Type t) { 1537 public Type apply(Type t) {
1533 if (t.hasTag(UNDETVAR)) { 1538 if (t.hasTag(UNDETVAR)) {
1534 UndetVar uv = (UndetVar)t; 1539 UndetVar uv = (UndetVar)t;
1535 return uv.qtype; 1540 return uv.inst != null ? uv.inst : uv.qtype;
1536 } else { 1541 } else {
1537 return t.map(this); 1542 return t.map(this);
1538 } 1543 }
1539 } 1544 }
1540 }; 1545 };

mercurial