Index: src/Validate/Autogen.cpp
===================================================================
--- src/Validate/Autogen.cpp	(revision 251ce804bfa9c794ec6fdf5d077a6553e6d749a4)
+++ src/Validate/Autogen.cpp	(revision 24d6572fc571b2a894d56a9335edd57899c448c0)
@@ -321,4 +321,16 @@
 void FuncGenerator::produceDecl( const ast::FunctionDecl * decl ) {
 	assert( nullptr != decl->stmts );
+	const auto & oldParams = getGenericParams(type);
+	assert( decl->type_params.size() == oldParams.size());
+
+	/*
+	ast::DeclReplacer::TypeMap typeMap;
+	for (auto it = oldParams.begin(), jt = decl->type_params.begin(); it != oldParams.end(); ++it, ++jt) {
+		typeMap.emplace(*it, *jt);
+	}
+
+	const ast::FunctionDecl * mut = strict_dynamic_cast<const ast::FunctionDecl *>(ast::DeclReplacer::replace(decl, typeMap));
+	assert (mut == decl);
+	*/
 
 	definitions.push_back( decl );
@@ -352,4 +364,6 @@
 	std::vector<ast::ptr<ast::TypeDecl>> type_params;
 	std::vector<ast::ptr<ast::DeclWithType>> assertions;
+
+	ast::DeclReplacer::TypeMap typeMap;
 	for ( auto & old_param : old_type_params ) {
 		ast::TypeDecl * decl = ast::deepCopy( old_param );
@@ -358,4 +372,12 @@
 		oldToNew.emplace( std::make_pair( old_param, decl ) );
 		type_params.push_back( decl );
+		typeMap.emplace(old_param, decl);
+	}
+
+	for (auto & param : params) {
+		param = ast::DeclReplacer::replace(param, typeMap);
+	}
+	for (auto & param : returns) {
+		param = ast::DeclReplacer::replace(param, typeMap);
 	}
 	replaceAll( params, oldToNew );
@@ -522,5 +544,5 @@
 	InitTweak::InitExpander_new srcParam( src );
 	// Assign to destination.
-	ast::Expr * dstSelect = new ast::MemberExpr(
+	ast::MemberExpr * dstSelect = new ast::MemberExpr(
 		location,
 		field,
@@ -574,5 +596,5 @@
 		}
 
-		ast::Expr * srcSelect = (srcParam) ? new ast::MemberExpr(
+		ast::MemberExpr * srcSelect = (srcParam) ? new ast::MemberExpr(
 			location, field, new ast::VariableExpr( location, srcParam )
 		) : nullptr;
