Index: src/GenPoly/FindFunction.cc
===================================================================
--- src/GenPoly/FindFunction.cc	(revision d29fa5fd0f3ac4c642952b5485abba72c11fb998)
+++ src/GenPoly/FindFunction.cc	(revision c366ec68d73cd23ab1a4b37dd84d4eb9ac2206be)
@@ -18,4 +18,5 @@
 #include <utility>                      // for pair
 
+#include "Common/PassVisitor.h"         // for PassVisitor
 #include "Common/SemanticError.h"       // for SemanticError
 #include "GenPoly/ErasableScopedMap.h"  // for ErasableScopedMap<>::iterator
@@ -27,10 +28,11 @@
 
 namespace GenPoly {
-	class FindFunction : public Mutator {
+	class FindFunction : public WithGuards, public WithVisitorRef<FindFunction>, public WithShortCircuiting {
 	  public:
 		FindFunction( std::list< FunctionType* > &functions, const TyVarMap &tyVars, bool replaceMode, FindFunctionPredicate predicate );
 
-		virtual Type *mutate( FunctionType *functionType );
-		virtual Type *mutate( PointerType *pointerType );
+		void premutate( FunctionType * functionType );
+		Type * postmutate( FunctionType * functionType );
+		void premutate( PointerType * pointerType );
 	  private:
 		void handleForall( const Type::ForallList &forall );
@@ -43,10 +45,10 @@
 
 	void findFunction( Type *type, std::list< FunctionType* > &functions, const TyVarMap &tyVars, FindFunctionPredicate predicate ) {
-		FindFunction finder( functions, tyVars, false, predicate );
+		PassVisitor<FindFunction> finder( functions, tyVars, false, predicate );
 		type->acceptMutator( finder );
 	}
 
 	void findAndReplaceFunction( Type *&type, std::list< FunctionType* > &functions, const TyVarMap &tyVars, FindFunctionPredicate predicate ) {
-		FindFunction finder( functions, tyVars, true, predicate );
+		PassVisitor<FindFunction> finder( functions, tyVars, true, predicate );
 		type = type->acceptMutator( finder );
 	}
@@ -57,6 +59,6 @@
 
 	void FindFunction::handleForall( const Type::ForallList &forall ) {
-		for ( Type::ForallList::const_iterator i = forall.begin(); i != forall.end(); ++i ) {
-			TyVarMap::iterator var = tyVars.find( (*i)->get_name() );
+		for ( const Declaration * td : forall ) {
+			TyVarMap::iterator var = tyVars.find( td->name );
 			if ( var != tyVars.end() ) {
 				tyVars.erase( var->first );
@@ -65,8 +67,12 @@
 	}
 
-	Type * FindFunction::mutate( FunctionType *functionType ) {
-		tyVars.beginScope();
+	void FindFunction::premutate( FunctionType * functionType ) {
+		visit_children = false;
+		GuardScope( tyVars );
 		handleForall( functionType->get_forall() );
-		mutateAll( functionType->get_returnVals(), *this );
+		mutateAll( functionType->get_returnVals(), *visitor );
+	}
+
+	Type * FindFunction::postmutate( FunctionType * functionType ) {
 		Type *ret = functionType;
 		if ( predicate( functionType, tyVars ) ) {
@@ -77,14 +83,10 @@
 			} // if
 		} // if
-		tyVars.endScope();
 		return ret;
 	}
 
-	Type * FindFunction::mutate( PointerType *pointerType ) {
-		tyVars.beginScope();
+	void FindFunction::premutate( PointerType * pointerType ) {
+		GuardScope( tyVars );
 		handleForall( pointerType->get_forall() );
-		Type *ret = Mutator::mutate( pointerType );
-		tyVars.endScope();
-		return ret;
 	}
 } // namespace GenPoly
