Index: src/ResolvExpr/Resolver.cc
===================================================================
--- src/ResolvExpr/Resolver.cc	(revision 99d45847f7626033f67b33afdf3e149972c747b0)
+++ src/ResolvExpr/Resolver.cc	(revision c6a1e8a0f90b4d3d3d79831a87ae966fa0927685)
@@ -29,4 +29,5 @@
 #include "typeops.h"                     // for extractResultType
 #include "Unify.h"                       // for unify
+#include "AST/Chain.hpp"
 #include "AST/Decl.hpp"
 #include "AST/Init.hpp"
@@ -410,8 +411,8 @@
 
 	void Resolver_old::previsit( ObjectDecl * objectDecl ) {
-		// To handle initialization of routine pointers, e.g., int (*fp)(int) = foo(), means that 
-		// class-variable initContext is changed multiple time because the LHS is analysed twice. 
-		// The second analysis changes initContext because of a function type can contain object 
-		// declarations in the return and parameter types. So each value of initContext is 
+		// To handle initialization of routine pointers, e.g., int (*fp)(int) = foo(), means that
+		// class-variable initContext is changed multiple time because the LHS is analysed twice.
+		// The second analysis changes initContext because of a function type can contain object
+		// declarations in the return and parameter types. So each value of initContext is
 		// retained, so the type on the first analysis is preserved and used for selecting the RHS.
 		GuardValue( currentObject );
@@ -450,5 +451,5 @@
 
 	void Resolver_old::postvisit( FunctionDecl * functionDecl ) {
-		// default value expressions have an environment which shouldn't be there and trips up 
+		// default value expressions have an environment which shouldn't be there and trips up
 		// later passes.
 		// xxx - it might be necessary to somehow keep the information from this environment, but I
@@ -1118,14 +1119,14 @@
 	}
 
-	class Resolver_new final 
-	: public ast::WithSymbolTable, public ast::WithGuards, 
-	  public ast::WithVisitorRef<Resolver_new>, public ast::WithShortCircuiting, 
+	class Resolver_new final
+	: public ast::WithSymbolTable, public ast::WithGuards,
+	  public ast::WithVisitorRef<Resolver_new>, public ast::WithShortCircuiting,
 	  public ast::WithStmtsToAdd<> {
-	
+
 		ast::ptr< ast::Type > functionReturn = nullptr;
 		// ast::CurrentObject currentObject = nullptr;
 		bool inEnumDecl = false;
 
-	public: 
+	public:
 		Resolver_new() = default;
 		Resolver_new( const ast::SymbolTable & syms ) { symtab = syms; }
@@ -1170,19 +1171,22 @@
 
 	const ast::FunctionDecl * Resolver_new::postvisit( const ast::FunctionDecl * functionDecl ) {
-		// default value expressions have an environment which shouldn't be there and trips up 
+		// default value expressions have an environment which shouldn't be there and trips up
 		// later passes.
 		ast::ptr< ast::FunctionDecl > ret = functionDecl;
 		for ( unsigned i = 0; i < functionDecl->type->params.size(); ++i ) {
 			const ast::ptr<ast::DeclWithType> & d = functionDecl->type->params[i];
-			
+
 			if ( const ast::ObjectDecl * obj = d.as< ast::ObjectDecl >() ) {
 				if ( const ast::SingleInit * init = obj->init.as< ast::SingleInit >() ) {
 					if ( init->value->env == nullptr ) continue;
 					// clone initializer minus the initializer environment
-					strict_dynamic_cast< ast::SingleInit * >(
-						strict_dynamic_cast< ast::ObjectDecl * >( 
-							ret.get_and_mutate()->type.get_and_mutate()->params[i].get_and_mutate()
-						)->init.get_and_mutate()
-					)->value.get_and_mutate()->env = nullptr;
+					ast::chain_mutate( ret )
+						( &ast::FunctionDecl::type )
+							( &ast::FunctionType::params )[i]
+								( &ast::ObjectDecl::init )
+									( &ast::SingleInit::value )->env = nullptr;
+
+					assert( functionDecl != ret.get() || functionDecl->unique() );
+					assert( ! ret->type->params[i].strict_as< ast::ObjectDecl >()->init.strict_as< ast::SingleInit >()->value->env );
 				}
 			}
