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

changeset 1898
a204cf7aab7e
parent 1891
42b3c5e92461
child 1905
f65a807714ba
     1.1 --- a/src/share/classes/com/sun/tools/javac/code/Type.java	Wed Jul 17 14:09:46 2013 +0100
     1.2 +++ b/src/share/classes/com/sun/tools/javac/code/Type.java	Wed Jul 17 14:11:41 2013 +0100
     1.3 @@ -1452,7 +1452,7 @@
     1.4          }
     1.5  
     1.6          /** inference variable bounds */
     1.7 -        private Map<InferenceBound, List<Type>> bounds;
     1.8 +        protected Map<InferenceBound, List<Type>> bounds;
     1.9  
    1.10          /** inference variable's inferred type (set from Infer.java) */
    1.11          public Type inst = null;
    1.12 @@ -1520,7 +1520,11 @@
    1.13          }
    1.14  
    1.15          /** add a bound of a given kind - this might trigger listener notification */
    1.16 -        public void addBound(InferenceBound ib, Type bound, Types types) {
    1.17 +        public final void addBound(InferenceBound ib, Type bound, Types types) {
    1.18 +            addBound(ib, bound, types, false);
    1.19 +        }
    1.20 +
    1.21 +        protected void addBound(InferenceBound ib, Type bound, Types types, boolean update) {
    1.22              Type bound2 = boundMap.apply(bound);
    1.23              List<Type> prevBounds = bounds.get(ib);
    1.24              for (Type b : prevBounds) {
    1.25 @@ -1575,7 +1579,7 @@
    1.26                      bounds.put(ib, newBounds.toList());
    1.27                      //step 3 - for each dependency, add new replaced bound
    1.28                      for (Type dep : deps) {
    1.29 -                        addBound(ib, types.subst(dep, from, to), types);
    1.30 +                        addBound(ib, types.subst(dep, from, to), types, true);
    1.31                      }
    1.32                  }
    1.33              } finally {
    1.34 @@ -1591,6 +1595,39 @@
    1.35                  listener.varChanged(this, ibs);
    1.36              }
    1.37          }
    1.38 +
    1.39 +        public boolean isCaptured() {
    1.40 +            return false;
    1.41 +        }
    1.42 +    }
    1.43 +
    1.44 +    /**
    1.45 +     * This class is used to represent synthetic captured inference variables
    1.46 +     * that can be generated during nested generic method calls. The only difference
    1.47 +     * between these inference variables and ordinary ones is that captured inference
    1.48 +     * variables cannot get new bounds through incorporation.
    1.49 +     */
    1.50 +    public static class CapturedUndetVar extends UndetVar {
    1.51 +
    1.52 +        public CapturedUndetVar(CapturedType origin, Types types) {
    1.53 +            super(origin, types);
    1.54 +            if (!origin.lower.hasTag(BOT)) {
    1.55 +                bounds.put(InferenceBound.LOWER, List.of(origin.lower));
    1.56 +            }
    1.57 +        }
    1.58 +
    1.59 +        @Override
    1.60 +        public void addBound(InferenceBound ib, Type bound, Types types, boolean update) {
    1.61 +            if (update) {
    1.62 +                //only change bounds if request comes from substBounds
    1.63 +                super.addBound(ib, bound, types, update);
    1.64 +            }
    1.65 +        }
    1.66 +
    1.67 +        @Override
    1.68 +        public boolean isCaptured() {
    1.69 +            return true;
    1.70 +        }
    1.71      }
    1.72  
    1.73      /** Represents NONE.

mercurial