langtools/src/share/classes/com/sun/tools/javac/code/Types.java
changeset 8430 be3e5581ea25
parent 8427 703181b01773
child 8617 6a05d1669247
equal deleted inserted replaced
8429:510df4cd65d7 8430:be3e5581ea25
  2405     static private Mapping newInstanceFun = new Mapping("newInstanceFun") {
  2405     static private Mapping newInstanceFun = new Mapping("newInstanceFun") {
  2406             public Type apply(Type t) { return new TypeVar(t.tsym, t.getUpperBound(), t.getLowerBound()); }
  2406             public Type apply(Type t) { return new TypeVar(t.tsym, t.getUpperBound(), t.getLowerBound()); }
  2407         };
  2407         };
  2408     // </editor-fold>
  2408     // </editor-fold>
  2409 
  2409 
       
  2410     public Type createMethodTypeWithParameters(Type original, List<Type> newParams) {
       
  2411         return original.accept(methodWithParameters, newParams);
       
  2412     }
       
  2413     // where
       
  2414         private final MapVisitor<List<Type>> methodWithParameters = new MapVisitor<List<Type>>() {
       
  2415             public Type visitType(Type t, List<Type> newParams) {
       
  2416                 throw new IllegalArgumentException("Not a method type: " + t);
       
  2417             }
       
  2418             public Type visitMethodType(MethodType t, List<Type> newParams) {
       
  2419                 return new MethodType(newParams, t.restype, t.thrown, t.tsym);
       
  2420             }
       
  2421             public Type visitForAll(ForAll t, List<Type> newParams) {
       
  2422                 return new ForAll(t.tvars, t.qtype.accept(this, newParams));
       
  2423             }
       
  2424         };
       
  2425 
       
  2426     public Type createMethodTypeWithThrown(Type original, List<Type> newThrown) {
       
  2427         return original.accept(methodWithThrown, newThrown);
       
  2428     }
       
  2429     // where
       
  2430         private final MapVisitor<List<Type>> methodWithThrown = new MapVisitor<List<Type>>() {
       
  2431             public Type visitType(Type t, List<Type> newThrown) {
       
  2432                 throw new IllegalArgumentException("Not a method type: " + t);
       
  2433             }
       
  2434             public Type visitMethodType(MethodType t, List<Type> newThrown) {
       
  2435                 return new MethodType(t.argtypes, t.restype, newThrown, t.tsym);
       
  2436             }
       
  2437             public Type visitForAll(ForAll t, List<Type> newThrown) {
       
  2438                 return new ForAll(t.tvars, t.qtype.accept(this, newThrown));
       
  2439             }
       
  2440         };
       
  2441 
  2410     // <editor-fold defaultstate="collapsed" desc="createErrorType">
  2442     // <editor-fold defaultstate="collapsed" desc="createErrorType">
  2411     public Type createErrorType(Type originalType) {
  2443     public Type createErrorType(Type originalType) {
  2412         return new ErrorType(originalType, syms.errSymbol);
  2444         return new ErrorType(originalType, syms.errSymbol);
  2413     }
  2445     }
  2414 
  2446