1.1 --- a/src/share/classes/com/sun/tools/javac/code/Types.java Tue Mar 29 16:40:31 2011 +0100 1.2 +++ b/src/share/classes/com/sun/tools/javac/code/Types.java Tue Mar 29 16:40:51 2011 +0100 1.3 @@ -2461,6 +2461,22 @@ 1.4 } 1.5 }; 1.6 1.7 + public Type createMethodTypeWithReturn(Type original, Type newReturn) { 1.8 + return original.accept(methodWithReturn, newReturn); 1.9 + } 1.10 + // where 1.11 + private final MapVisitor<Type> methodWithReturn = new MapVisitor<Type>() { 1.12 + public Type visitType(Type t, Type newReturn) { 1.13 + throw new IllegalArgumentException("Not a method type: " + t); 1.14 + } 1.15 + public Type visitMethodType(MethodType t, Type newReturn) { 1.16 + return new MethodType(t.argtypes, newReturn, t.thrown, t.tsym); 1.17 + } 1.18 + public Type visitForAll(ForAll t, Type newReturn) { 1.19 + return new ForAll(t.tvars, t.qtype.accept(this, newReturn)); 1.20 + } 1.21 + }; 1.22 + 1.23 // <editor-fold defaultstate="collapsed" desc="createErrorType"> 1.24 public Type createErrorType(Type originalType) { 1.25 return new ErrorType(originalType, syms.errSymbol);