Index: src/GenPoly/Box.cc
===================================================================
--- src/GenPoly/Box.cc	(revision ebe9b3a3d574e360214e7e825ea7414a364d9b0e)
+++ src/GenPoly/Box.cc	(revision aadc9a43076d3a15ac9194297e715a207cc767cc)
@@ -231,6 +231,5 @@
 				// process polymorphic return value
 				retval = 0;
-				std::string typeName;
-				if ( isPolyRet( functionDecl->get_functionType(), typeName ) && functionDecl->get_linkage() == LinkageSpec::Cforall ) {
+				if ( isPolyRet( functionDecl->get_functionType() ) && functionDecl->get_linkage() == LinkageSpec::Cforall ) {
 					retval = functionDecl->get_functionType()->get_returnVals().front();
 
@@ -787,7 +786,6 @@
 			std::list< Expression *>::iterator paramBegin = appExpr->get_args().begin();
 
-			std::string typeName;
-			if ( isPolyRet( function, typeName ) ) {
-				ret = addPolyRetParam( appExpr, function, typeName, arg );
+			if ( ReferenceToType *polyType = isPolyRet( function ) ) {
+				ret = addPolyRetParam( appExpr, function, polyType->get_name(), arg );
 			} else if ( needsAdapter( function, scopeTyVars ) ) {
 				// std::cerr << "needs adapter: ";
@@ -994,6 +992,5 @@
 
 			// move polymorphic return type to parameter list
-			std::string typeName;
-			if ( isPolyRet( funcType, typeName ) ) {
+			if ( isPolyRet( funcType ) ) {
 				DeclarationWithType *ret = funcType->get_returnVals().front();
 				ret->set_type( new PointerType( Type::Qualifiers(), ret->get_type() ) );
Index: src/GenPoly/GenPoly.cc
===================================================================
--- src/GenPoly/GenPoly.cc	(revision ebe9b3a3d574e360214e7e825ea7414a364d9b0e)
+++ src/GenPoly/GenPoly.cc	(revision aadc9a43076d3a15ac9194297e715a207cc767cc)
@@ -36,33 +36,11 @@
 	}
 
-	bool isPolyRet( FunctionType *function, std::string &name, const TyVarMap &otherTyVars ) {
-		bool doTransform = false;
+	ReferenceToType *isPolyRet( FunctionType *function ) {
 		if ( ! function->get_returnVals().empty() ) {
-			if ( TypeInstType *typeInst = dynamic_cast< TypeInstType *>( function->get_returnVals().front()->get_type() ) ) {
-	
-				// figure out if the return type is specified by a type parameter
-				for ( std::list< TypeDecl *>::const_iterator tyVar = function->get_forall().begin(); tyVar != function->get_forall().end(); ++tyVar ) {
-					if ( (*tyVar)->get_name() == typeInst->get_name() ) {
-						doTransform = true;
-						name = typeInst->get_name();
-						break;
-					} // if
-				} // for
-				if ( ! doTransform && otherTyVars.find( typeInst->get_name() ) != otherTyVars.end() ) {
-					doTransform = true;
-				} // if
-			} // if
+			TyVarMap forallTypes;
+			makeTyVarMap( function, forallTypes );
+			return (ReferenceToType*)isPolyType( function->get_returnVals().front()->get_type(), forallTypes );
 		} // if
-		return doTransform;
-	}
-
-	bool isPolyRet( FunctionType *function, std::string &name ) {
-		TyVarMap dummyTyVars;
-		return isPolyRet( function, name, dummyTyVars );
-	}
-
-	bool isPolyRet( FunctionType *function, const TyVarMap &otherTyVars ) {
-		std::string dummyString;
-		return isPolyRet( function, dummyString, otherTyVars );
+		return 0;
 	}
 
@@ -158,4 +136,14 @@
 	}
 
+	void makeTyVarMap( Type *type, TyVarMap &tyVarMap ) {
+		for ( std::list< TypeDecl* >::const_iterator tyVar = type->get_forall().begin(); tyVar != type->get_forall().end(); ++tyVar ) {
+			assert( *tyVar );
+			tyVarMap[ (*tyVar)->get_name() ] = (*tyVar)->get_kind();
+		}
+		if ( PointerType *pointer = dynamic_cast< PointerType* >( type ) ) {
+			makeTyVarMap( pointer->get_base(), tyVarMap );
+		}
+	}
+	
 	void printTyVarMap( std::ostream &os, const TyVarMap &tyVarMap ) {
 		for ( TyVarMap::const_iterator i = tyVarMap.begin(); i != tyVarMap.end(); ++i ) {
Index: src/GenPoly/GenPoly.h
===================================================================
--- src/GenPoly/GenPoly.h	(revision ebe9b3a3d574e360214e7e825ea7414a364d9b0e)
+++ src/GenPoly/GenPoly.h	(revision aadc9a43076d3a15ac9194297e715a207cc767cc)
@@ -22,4 +22,5 @@
 
 #include "SynTree/Declaration.h"
+#include "SynTree/Type.h"
 #include "SynTree/TypeSubstitution.h"
 
@@ -32,7 +33,5 @@
 
 	/// true iff function has polymorphic return type
-	bool isPolyRet( FunctionType *function, std::string &name, const TyVarMap &otherTyVars );
-	bool isPolyRet( FunctionType *function, std::string &name );
-	bool isPolyRet( FunctionType *function, const TyVarMap &otherTyVars );
+	ReferenceToType *isPolyRet( FunctionType *function );
 
 	/// returns polymorphic type if is polymorphic type, NULL otherwise; will look up substitution in env if provided
@@ -51,4 +50,7 @@
 	FunctionType * getFunctionType( Type *ty );
 
+	/// Adds the declarations in the forall list of type (and its pointed-to type if it's a pointer type) to `tyVarMap`
+	void makeTyVarMap( Type *type, TyVarMap &tyVarMap );
+	
 	/// Prints type variable map
 	void printTyVarMap( std::ostream &os, const TyVarMap &tyVarMap );
Index: src/GenPoly/PolyMutator.cc
===================================================================
--- src/GenPoly/PolyMutator.cc	(revision ebe9b3a3d574e360214e7e825ea7414a364d9b0e)
+++ src/GenPoly/PolyMutator.cc	(revision aadc9a43076d3a15ac9194297e715a207cc767cc)
@@ -152,15 +152,4 @@
 	}
 
-
-	/* static class method */
-	void PolyMutator::makeTyVarMap( Type *type, TyVarMap &tyVarMap ) {
-		for ( std::list< TypeDecl* >::const_iterator tyVar = type->get_forall().begin(); tyVar != type->get_forall().end(); ++tyVar ) {
-			assert( *tyVar );
-			tyVarMap[ (*tyVar)->get_name() ] = (*tyVar)->get_kind();
-		}
-		if ( PointerType *pointer = dynamic_cast< PointerType* >( type ) ) {
-			makeTyVarMap( pointer->get_base(), tyVarMap );
-		}
-	}
 } // namespace GenPoly
 
Index: src/GenPoly/PolyMutator.h
===================================================================
--- src/GenPoly/PolyMutator.h	(revision ebe9b3a3d574e360214e7e825ea7414a364d9b0e)
+++ src/GenPoly/PolyMutator.h	(revision aadc9a43076d3a15ac9194297e715a207cc767cc)
@@ -51,6 +51,4 @@
 		virtual void doBeginScope() {}
 		virtual void doEndScope() {}
-		
-		static void makeTyVarMap( Type *type, TyVarMap &tyVarMap );
 	  protected:
 		void mutateStatementList( std::list< Statement* > &statements );
