langtools/src/share/classes/com/sun/tools/javac/code/Types.java
changeset 1790 7182011ee8a6
parent 1535 a64c289fe413
child 1792 985e9406d42a
equal deleted inserted replaced
1789:7ac8c0815000 1790:7182011ee8a6
   878             return allowBoxing && isConvertible(t, s, warn);
   878             return allowBoxing && isConvertible(t, s, warn);
   879 
   879 
   880         if (warn != warnStack.head) {
   880         if (warn != warnStack.head) {
   881             try {
   881             try {
   882                 warnStack = warnStack.prepend(warn);
   882                 warnStack = warnStack.prepend(warn);
   883                 return isCastable.visit(t, s);
   883                 return isCastable.visit(t,s);
   884             } finally {
   884             } finally {
   885                 warnStack = warnStack.tail;
   885                 warnStack = warnStack.tail;
   886             }
   886             }
   887         } else {
   887         } else {
   888             return isCastable.visit(t, s);
   888             return isCastable.visit(t,s);
   889         }
   889         }
   890     }
   890     }
   891     // where
   891     // where
   892         private TypeRelation isCastable = new TypeRelation() {
   892         private TypeRelation isCastable = new TypeRelation() {
   893 
   893 
   981                             highSub = (lowSub == null) ? null : asSub(bHigh, aHigh.tsym);
   981                             highSub = (lowSub == null) ? null : asSub(bHigh, aHigh.tsym);
   982                         }
   982                         }
   983                         if (highSub != null) {
   983                         if (highSub != null) {
   984                             assert a.tsym == highSub.tsym && a.tsym == lowSub.tsym
   984                             assert a.tsym == highSub.tsym && a.tsym == lowSub.tsym
   985                                 : a.tsym + " != " + highSub.tsym + " != " + lowSub.tsym;
   985                                 : a.tsym + " != " + highSub.tsym + " != " + lowSub.tsym;
   986                             if (!disjointTypes(aHigh.getTypeArguments(), highSub.getTypeArguments())
   986                             if (!disjointTypes(aHigh.allparams(), highSub.allparams())
   987                                 && !disjointTypes(aHigh.getTypeArguments(), lowSub.getTypeArguments())
   987                                 && !disjointTypes(aHigh.allparams(), lowSub.allparams())
   988                                 && !disjointTypes(aLow.getTypeArguments(), highSub.getTypeArguments())
   988                                 && !disjointTypes(aLow.allparams(), highSub.allparams())
   989                                 && !disjointTypes(aLow.getTypeArguments(), lowSub.getTypeArguments())) {
   989                                 && !disjointTypes(aLow.allparams(), lowSub.allparams())) {
   990                                 if (upcast ? giveWarning(a, highSub) || giveWarning(a, lowSub)
   990                                 if (upcast ? giveWarning(a, highSub) || giveWarning(a, lowSub)
   991                                            : giveWarning(highSub, a) || giveWarning(lowSub, a))
   991                                            : giveWarning(highSub, a) || giveWarning(lowSub, a))
   992                                     warnStack.head.warnUnchecked();
   992                                     warnStack.head.warnUnchecked();
   993                                 return true;
   993                                 return true;
   994                             }
   994                             }
  1195         }
  1195         }
  1196         if (s.tag != WILDCARD)
  1196         if (s.tag != WILDCARD)
  1197             s = upperBound(s);
  1197             s = upperBound(s);
  1198         if (s.tag == TYPEVAR)
  1198         if (s.tag == TYPEVAR)
  1199             s = s.getUpperBound();
  1199             s = s.getUpperBound();
       
  1200 
  1200         return !isSubtype(t, s);
  1201         return !isSubtype(t, s);
  1201     }
  1202     }
  1202     // </editor-fold>
  1203     // </editor-fold>
  1203 
  1204 
  1204     // <editor-fold defaultstate="collapsed" desc="isReifiable">
  1205     // <editor-fold defaultstate="collapsed" desc="isReifiable">
  3187     }
  3188     }
  3188 
  3189 
  3189     private boolean giveWarning(Type from, Type to) {
  3190     private boolean giveWarning(Type from, Type to) {
  3190         // To and from are (possibly different) parameterizations
  3191         // To and from are (possibly different) parameterizations
  3191         // of the same class or interface
  3192         // of the same class or interface
  3192         return to.isParameterized() && !containsType(to.getTypeArguments(), from.getTypeArguments());
  3193         return to.isParameterized() && !containsType(to.allparams(), from.allparams());
  3193     }
  3194     }
  3194 
  3195 
  3195     private List<Type> superClosure(Type t, Type s) {
  3196     private List<Type> superClosure(Type t, Type s) {
  3196         List<Type> cl = List.nil();
  3197         List<Type> cl = List.nil();
  3197         for (List<Type> l = interfaces(t); l.nonEmpty(); l = l.tail) {
  3198         for (List<Type> l = interfaces(t); l.nonEmpty(); l = l.tail) {