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

changeset 896
9f9df9684cfc
parent 880
0c24826853b2
child 904
4baab658f357
     1.1 --- a/src/share/classes/com/sun/tools/javac/code/Types.java	Mon Feb 28 11:48:53 2011 +0000
     1.2 +++ b/src/share/classes/com/sun/tools/javac/code/Types.java	Mon Feb 28 11:50:56 2011 +0000
     1.3 @@ -2832,12 +2832,26 @@
     1.4              while (ts.head.tag != CLASS && ts.head.tag != TYPEVAR)
     1.5                  ts = ts.tail;
     1.6              Assert.check(!ts.isEmpty());
     1.7 -            List<Type> cl = closure(ts.head);
     1.8 +            //step 1 - compute erased candidate set (EC)
     1.9 +            List<Type> cl = erasedSupertypes(ts.head);
    1.10              for (Type t : ts.tail) {
    1.11                  if (t.tag == CLASS || t.tag == TYPEVAR)
    1.12 -                    cl = intersect(cl, closure(t));
    1.13 +                    cl = intersect(cl, erasedSupertypes(t));
    1.14              }
    1.15 -            return compoundMin(cl);
    1.16 +            //step 2 - compute minimal erased candidate set (MEC)
    1.17 +            List<Type> mec = closureMin(cl);
    1.18 +            //step 3 - for each element G in MEC, compute lci(Inv(G))
    1.19 +            List<Type> candidates = List.nil();
    1.20 +            for (Type erasedSupertype : mec) {
    1.21 +                List<Type> lci = List.of(asSuper(ts.head, erasedSupertype.tsym));
    1.22 +                for (Type t : ts) {
    1.23 +                    lci = intersect(lci, List.of(asSuper(t, erasedSupertype.tsym)));
    1.24 +                }
    1.25 +                candidates = candidates.appendList(lci);
    1.26 +            }
    1.27 +            //step 4 - let MEC be { G1, G2 ... Gn }, then we have that
    1.28 +            //lub = lci(Inv(G1)) & lci(Inv(G2)) & ... & lci(Inv(Gn))
    1.29 +            return compoundMin(candidates);
    1.30  
    1.31          default:
    1.32              // calculate lub(A, B[])
    1.33 @@ -2851,6 +2865,18 @@
    1.34          }
    1.35      }
    1.36      // where
    1.37 +        List<Type> erasedSupertypes(Type t) {
    1.38 +            ListBuffer<Type> buf = lb();
    1.39 +            for (Type sup : closure(t)) {
    1.40 +                if (sup.tag == TYPEVAR) {
    1.41 +                    buf.append(sup);
    1.42 +                } else {
    1.43 +                    buf.append(erasure(sup));
    1.44 +                }
    1.45 +            }
    1.46 +            return buf.toList();
    1.47 +        }
    1.48 +
    1.49          private Type arraySuperType = null;
    1.50          private Type arraySuperType() {
    1.51              // initialized lazily to avoid problems during compiler startup

mercurial