langtools/src/share/classes/com/sun/tools/javac/code/Types.java
changeset 9075 cba34854a40e
parent 8628 9e31f1c01bd4
child 9301 da48f63f0b22
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Types.java	Tue Mar 29 16:40:31 2011 +0100
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Types.java	Tue Mar 29 16:40:51 2011 +0100
@@ -2461,6 +2461,22 @@
             }
         };
 
+    public Type createMethodTypeWithReturn(Type original, Type newReturn) {
+        return original.accept(methodWithReturn, newReturn);
+    }
+    // where
+        private final MapVisitor<Type> methodWithReturn = new MapVisitor<Type>() {
+            public Type visitType(Type t, Type newReturn) {
+                throw new IllegalArgumentException("Not a method type: " + t);
+            }
+            public Type visitMethodType(MethodType t, Type newReturn) {
+                return new MethodType(t.argtypes, newReturn, t.thrown, t.tsym);
+            }
+            public Type visitForAll(ForAll t, Type newReturn) {
+                return new ForAll(t.tvars, t.qtype.accept(this, newReturn));
+            }
+        };
+
     // <editor-fold defaultstate="collapsed" desc="createErrorType">
     public Type createErrorType(Type originalType) {
         return new ErrorType(originalType, syms.errSymbol);