Index: src/SynTree/CompoundStmt.cc
===================================================================
--- src/SynTree/CompoundStmt.cc	(revision f6e3e345e94a983a197c49451c099ac2783fca51)
+++ src/SynTree/CompoundStmt.cc	(revision 7862059cce5f318d65bb3ffe71be2e849497ea0b)
@@ -23,5 +23,5 @@
 #include "Statement.h"                // for CompoundStmt, Statement, DeclStmt
 #include "SynTree/Label.h"            // for Label
-#include "SynTree/VarExprReplacer.h"  // for VarExprReplacer, VarExprReplace...
+#include "SynTree/DeclReplacer.h"     // for DeclReplacer
 
 using std::string;
@@ -49,5 +49,5 @@
 	// recursively execute this routine. There may be more efficient ways of doing
 	// this.
-	VarExprReplacer::DeclMap declMap;
+	DeclReplacer::DeclMap declMap;
 	std::list< Statement * >::const_iterator origit = other.kids.begin();
 	for ( Statement * s : kids ) {
@@ -64,5 +64,5 @@
 	}
 	if ( ! declMap.empty() ) {
-		VarExprReplacer::replace( this, declMap );
+		DeclReplacer::replace( this, declMap );
 	}
 }
Index: src/SynTree/DeclReplacer.cc
===================================================================
--- src/SynTree/DeclReplacer.cc	(revision 7862059cce5f318d65bb3ffe71be2e849497ea0b)
+++ src/SynTree/DeclReplacer.cc	(revision 7862059cce5f318d65bb3ffe71be2e849497ea0b)
@@ -0,0 +1,82 @@
+//
+// Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo
+//
+// The contents of this file are covered under the licence agreement in the
+// file "LICENCE" distributed with Cforall.
+//
+// VarExprReplacer.h --
+//
+// Author           : Rob Schluntz
+// Created On       : Wed Jan 13 16:29:30 2016
+// Last Modified By : Rob Schluntz
+// Last Modified On : Fri May 13 11:27:52 2016
+// Update Count     : 5
+//
+
+#include <iostream>       // for operator<<, basic_ostream, ostream, basic_o...
+
+#include "Common/PassVisitor.h"
+#include "Declaration.h"  // for operator<<, DeclarationWithType
+#include "Expression.h"   // for VariableExpr
+#include "DeclReplacer.h"
+
+namespace DeclReplacer {
+	namespace {
+		/// Visitor that replaces the declarations that VariableExprs refer to, according to the supplied mapping
+		struct DeclReplacer {
+		private:
+			const DeclMap & declMap;
+			const TypeMap & typeMap;
+			bool debug;
+		public:
+			DeclReplacer( const DeclMap & declMap, const TypeMap & typeMap, bool debug = false );
+
+			// replace variable with new node from decl map
+			void previsit( VariableExpr * varExpr );
+
+			// replace type inst with new node from type map
+			void previsit( TypeInstType * inst );
+		};
+	}
+
+	void replace( BaseSyntaxNode * node, const DeclMap & declMap, const TypeMap & typeMap, bool debug ) {
+		PassVisitor<DeclReplacer> replacer( declMap, typeMap, debug );
+		maybeAccept( node, replacer );
+	}
+
+	void replace( BaseSyntaxNode * node, const DeclMap & declMap, bool debug ) {
+		TypeMap typeMap;
+		replace( node, declMap, typeMap, debug );
+	}
+
+	void replace( BaseSyntaxNode * node, const TypeMap & typeMap, bool debug ) {
+		DeclMap declMap;
+		replace( node, declMap, typeMap, debug );
+	}
+
+	namespace {
+		DeclReplacer::DeclReplacer( const DeclMap & declMap, const TypeMap & typeMap, bool debug ) : declMap( declMap ), typeMap( typeMap ) , debug( debug ) {}
+
+		// replace variable with new node from decl map
+		void DeclReplacer::previsit( VariableExpr * varExpr ) {
+			// xxx - assertions and parameters aren't accounted for in this... (i.e. they aren't inserted into the map when it's made, only DeclStmts are)
+			if ( declMap.count( varExpr->var ) ) {
+				auto replacement = declMap.at( varExpr->var );
+				if ( debug ) {
+					std::cerr << "replacing variable reference: " << (void*)varExpr->var << " " << varExpr->var << " with " << (void*)replacement << " " << replacement << std::endl;
+				}
+				varExpr->var = replacement;
+			}
+		}
+
+		void DeclReplacer::previsit( TypeInstType * inst ) {
+			if ( typeMap.count( inst->baseType ) ) {
+				auto replacement = typeMap.at( inst->baseType );
+				if ( debug ) {
+					std::cerr << "replacing type reference: " << (void*)inst->baseType << " " << inst->baseType << " with " << (void*)replacement << " " << replacement << std::endl;
+				}
+				inst->baseType = replacement;
+			}
+		}
+	}
+} // namespace VarExprReplacer
Index: src/SynTree/DeclReplacer.h
===================================================================
--- src/SynTree/DeclReplacer.h	(revision 7862059cce5f318d65bb3ffe71be2e849497ea0b)
+++ src/SynTree/DeclReplacer.h	(revision 7862059cce5f318d65bb3ffe71be2e849497ea0b)
@@ -0,0 +1,38 @@
+//
+// Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo
+//
+// The contents of this file are covered under the licence agreement in the
+// file "LICENCE" distributed with Cforall.
+//
+// VarExprReplacer.h --
+//
+// Author           : Rob Schluntz
+// Created On       : Wed Jan 13 16:29:30 2016
+// Last Modified By : Peter A. Buhr
+// Last Modified On : Sat Jul 22 09:53:41 2017
+// Update Count     : 6
+//
+
+#pragma once
+
+#include <map>                // for map, map<>::value_compare
+
+#include "SynTree/Visitor.h"  // for Visitor
+
+class DeclarationWithType;
+class VariableExpr;
+
+namespace DeclReplacer {
+	typedef std::map< DeclarationWithType *, DeclarationWithType * > DeclMap;
+	typedef std::map< TypeDecl *, TypeDecl * > TypeMap;
+
+	void replace( BaseSyntaxNode * node, const DeclMap & declMap, bool debug = false );
+	void replace( BaseSyntaxNode * node, const TypeMap & typeMap, bool debug = false );
+	void replace( BaseSyntaxNode * node, const DeclMap & declMap, const TypeMap & typeMap, bool debug = false );
+}
+
+// Local Variables: //
+// tab-width: 4 //
+// mode: c++ //
+// compile-command: "make install" //
+// End: //
Index: src/SynTree/FunctionDecl.cc
===================================================================
--- src/SynTree/FunctionDecl.cc	(revision f6e3e345e94a983a197c49451c099ac2783fca51)
+++ src/SynTree/FunctionDecl.cc	(revision 7862059cce5f318d65bb3ffe71be2e849497ea0b)
@@ -26,5 +26,5 @@
 #include "Statement.h"           // for CompoundStmt
 #include "Type.h"                // for Type, FunctionType, Type::FuncSpecif...
-#include "VarExprReplacer.h"
+#include "DeclReplacer.h"
 
 extern bool translation_unit_nomain;
@@ -41,5 +41,5 @@
 		: Parent( other ), type( maybeClone( other.type ) ), statements( maybeClone( other.statements ) ) {
 
-	VarExprReplacer::DeclMap declMap;
+	DeclReplacer::DeclMap declMap;
 	for ( auto p : group_iterate( other.type->parameters, type->parameters ) ) {
 		declMap[ std::get<0>(p) ] = std::get<1>(p);
@@ -49,5 +49,5 @@
 	}
 	if ( ! declMap.empty() ) {
-		VarExprReplacer::replace( this, declMap );
+		DeclReplacer::replace( this, declMap );
 	}
 	cloneAll( other.withExprs, withExprs );
Index: src/SynTree/VarExprReplacer.cc
===================================================================
--- src/SynTree/VarExprReplacer.cc	(revision f6e3e345e94a983a197c49451c099ac2783fca51)
+++ 	(revision )
@@ -1,64 +1,0 @@
-//
-// Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo
-//
-// The contents of this file are covered under the licence agreement in the
-// file "LICENCE" distributed with Cforall.
-//
-// VarExprReplacer.h --
-//
-// Author           : Rob Schluntz
-// Created On       : Wed Jan 13 16:29:30 2016
-// Last Modified By : Rob Schluntz
-// Last Modified On : Fri May 13 11:27:52 2016
-// Update Count     : 5
-//
-
-#include <iostream>       // for operator<<, basic_ostream, ostream, basic_o...
-
-#include "Common/PassVisitor.h"
-#include "Declaration.h"  // for operator<<, DeclarationWithType
-#include "Expression.h"   // for VariableExpr
-#include "VarExprReplacer.h"
-
-namespace VarExprReplacer {
-	namespace {
-		/// Visitor that replaces the declarations that VariableExprs refer to, according to the supplied mapping
-		struct VarExprReplacer {
-		private:
-			const DeclMap & declMap;
-			bool debug;
-		public:
-			VarExprReplacer( const DeclMap & declMap, bool debug = false );
-
-			// replace variable with new node from decl map
-			void previsit( VariableExpr * varExpr );
-		};
-	}
-
-	void replace( BaseSyntaxNode * node, const DeclMap & declMap, bool debug ) {
-		PassVisitor<VarExprReplacer> replacer( declMap, debug );
-		maybeAccept( node, replacer );
-	}
-
-	namespace {
-		VarExprReplacer::VarExprReplacer( const DeclMap & declMap, bool debug ) : declMap( declMap ), debug( debug ) {}
-
-		// replace variable with new node from decl map
-		void VarExprReplacer::previsit( VariableExpr * varExpr ) {
-			// xxx - assertions and parameters aren't accounted for in this... (i.e. they aren't inserted into the map when it's made, only DeclStmts are)
-			if ( declMap.count( varExpr->var ) ) {
-				if ( debug ) {
-					std::cerr << "replacing variable reference: " << (void*)varExpr->var << " " << varExpr->var << " with " << (void*)declMap.at( varExpr->var ) << " " << declMap.at( varExpr->var ) << std::endl;
-				}
-				varExpr->var = declMap.at( varExpr->var );
-			}
-		}
-	}
-} // namespace VarExprReplacer
-
-
-
-
-
-
-
Index: src/SynTree/VarExprReplacer.h
===================================================================
--- src/SynTree/VarExprReplacer.h	(revision f6e3e345e94a983a197c49451c099ac2783fca51)
+++ 	(revision )
@@ -1,35 +1,0 @@
-//
-// Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo
-//
-// The contents of this file are covered under the licence agreement in the
-// file "LICENCE" distributed with Cforall.
-//
-// VarExprReplacer.h --
-//
-// Author           : Rob Schluntz
-// Created On       : Wed Jan 13 16:29:30 2016
-// Last Modified By : Peter A. Buhr
-// Last Modified On : Sat Jul 22 09:53:41 2017
-// Update Count     : 6
-//
-
-#pragma once
-
-#include <map>                // for map, map<>::value_compare
-
-#include "SynTree/Visitor.h"  // for Visitor
-
-class DeclarationWithType;
-class VariableExpr;
-
-namespace VarExprReplacer {
-	typedef std::map< DeclarationWithType *, DeclarationWithType * > DeclMap;
-
-	void replace( BaseSyntaxNode * node, const DeclMap & declMap, bool debug = false );
-}
-
-// Local Variables: //
-// tab-width: 4 //
-// mode: c++ //
-// compile-command: "make install" //
-// End: //
Index: src/SynTree/module.mk
===================================================================
--- src/SynTree/module.mk	(revision f6e3e345e94a983a197c49451c099ac2783fca51)
+++ src/SynTree/module.mk	(revision 7862059cce5f318d65bb3ffe71be2e849497ea0b)
@@ -48,4 +48,4 @@
        SynTree/TypeSubstitution.cc \
        SynTree/Attribute.cc \
-       SynTree/VarExprReplacer.cc
+       SynTree/DeclReplacer.cc
 
