langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java
changeset 9074 76b505d19026
parent 8845 42fb82dfbf52
child 9075 cba34854a40e
equal deleted inserted replaced
9073:a29adf86aa0c 9074:76b505d19026
  2899         for (JCExpression typeTree : tree.alternatives) {
  2899         for (JCExpression typeTree : tree.alternatives) {
  2900             Type ctype = attribType(typeTree, env);
  2900             Type ctype = attribType(typeTree, env);
  2901             ctype = chk.checkType(typeTree.pos(),
  2901             ctype = chk.checkType(typeTree.pos(),
  2902                           chk.checkClassType(typeTree.pos(), ctype),
  2902                           chk.checkClassType(typeTree.pos(), ctype),
  2903                           syms.throwableType);
  2903                           syms.throwableType);
  2904             multicatchTypes.append(ctype);
  2904             if (!ctype.isErroneous()) {
       
  2905                 //check that alternatives of a disjunctive type are pairwise
       
  2906                 //unrelated w.r.t. subtyping
       
  2907                 if (chk.intersects(ctype,  multicatchTypes.toList())) {
       
  2908                     for (Type t : multicatchTypes) {
       
  2909                         boolean sub = types.isSubtype(ctype, t);
       
  2910                         boolean sup = types.isSubtype(t, ctype);
       
  2911                         if (sub || sup) {
       
  2912                             //assume 'a' <: 'b'
       
  2913                             Type a = sub ? ctype : t;
       
  2914                             Type b = sub ? t : ctype;
       
  2915                             log.error(typeTree.pos(), "multicatch.types.must.be.disjoint", a, b);
       
  2916                         }
       
  2917                     }
       
  2918                 }
       
  2919                 multicatchTypes.append(ctype);
       
  2920             }
  2905         }
  2921         }
  2906         tree.type = result = check(tree, types.lub(multicatchTypes.toList()), TYP, pkind, pt);
  2922         tree.type = result = check(tree, types.lub(multicatchTypes.toList()), TYP, pkind, pt);
  2907     }
  2923     }
  2908 
  2924 
  2909     public void visitTypeParameter(JCTypeParameter tree) {
  2925     public void visitTypeParameter(JCTypeParameter tree) {