Index: src/GenPoly/Specialize.cc
===================================================================
--- src/GenPoly/Specialize.cc	(revision 68195a628dc9339c2a4a40f3436aa4bfbcbbefb9)
+++ src/GenPoly/Specialize.cc	(revision bb666f649c7489fc5da7103d9f3f6dd470486575)
@@ -45,10 +45,9 @@
 	struct Specialize final : public WithTypeSubstitution, public WithStmtsToAdd, public WithVisitorRef<Specialize> {
 		Expression * postmutate( ApplicationExpr *applicationExpr );
-		Expression * postmutate( AddressExpr *castExpr );
 		Expression * postmutate( CastExpr *castExpr );
 
 		void handleExplicitParams( ApplicationExpr *appExpr );
 		Expression * createThunkFunction( FunctionType *funType, Expression *actual, InferredParams *inferParams );
-		Expression * doSpecialization( Type *formalType, Expression *actual, InferredParams *inferParams = nullptr );
+		Expression * doSpecialization( Type *formalType, Expression *actual, InferredParams *inferParams );
 
 		std::string paramPrefix = "_p";
@@ -131,7 +130,7 @@
 			if ( functionParameterSize( fftype ) != functionParameterSize( aftype ) ) return false;
 			// tuple-parameter sizes are the same, but actual parameter sizes differ - must tuple specialize
-			if ( fftype->get_parameters().size() != aftype->get_parameters().size() ) return true;
+			if ( fftype->parameters.size() != aftype->parameters.size() ) return true;
 			// total parameter size can be the same, while individual parameters can have different structure
-			for ( auto params : group_iterate( fftype->get_parameters(), aftype->get_parameters() ) ) {
+			for ( auto params : group_iterate( fftype->parameters, aftype->parameters ) ) {
 				DeclarationWithType * formal = std::get<0>(params);
 				DeclarationWithType * actual = std::get<1>(params);
@@ -150,9 +149,7 @@
 		if ( needsSpecialization( formalType, actual->get_result(), env ) ) {
 			if ( FunctionType *funType = getFunctionType( formalType ) ) {
-				ApplicationExpr *appExpr;
-				VariableExpr *varExpr;
-				if ( ( appExpr = dynamic_cast<ApplicationExpr*>( actual ) ) ) {
+				if ( ApplicationExpr * appExpr = dynamic_cast<ApplicationExpr*>( actual ) ) {
 					return createThunkFunction( funType, appExpr->get_function(), inferParams );
-				} else if ( ( varExpr = dynamic_cast<VariableExpr*>( actual ) ) ) {
+				} else if ( VariableExpr * varExpr = dynamic_cast<VariableExpr*>( actual ) ) {
 					return createThunkFunction( funType, varExpr, inferParams );
 				} else {
@@ -323,10 +320,4 @@
 	}
 
-	Expression * Specialize::postmutate( AddressExpr *addrExpr ) {
-		assert( addrExpr->result );
-		addrExpr->set_arg( doSpecialization( addrExpr->result, addrExpr->arg ) );
-		return addrExpr;
-	}
-
 	Expression * Specialize::postmutate( CastExpr *castExpr ) {
 		if ( castExpr->result->isVoid() ) {
@@ -334,5 +325,5 @@
 			return castExpr;
 		}
-		Expression *specialized = doSpecialization( castExpr->result, castExpr->arg );
+		Expression *specialized = doSpecialization( castExpr->result, castExpr->arg, &castExpr->inferParams );
 		if ( specialized != castExpr->arg ) {
 			// assume here that the specialization incorporates the cast
Index: src/ResolvExpr/AlternativeFinder.cc
===================================================================
--- src/ResolvExpr/AlternativeFinder.cc	(revision 68195a628dc9339c2a4a40f3436aa4bfbcbbefb9)
+++ src/ResolvExpr/AlternativeFinder.cc	(revision bb666f649c7489fc5da7103d9f3f6dd470486575)
@@ -319,12 +319,12 @@
 	Cost computeExpressionConversionCost( Expression *& actualExpr, Type * formalType, const SymTab::Indexer &indexer, const TypeEnvironment & env ) {
 		Cost convCost = computeConversionCost( actualExpr->result, formalType, indexer, env );
-		// if ( convCost != Cost::zero ) {
-
-		// xxx - temporary -- ignore poly cost, since this causes some polymorphic functions to be cast, which causes the specialize
-		// pass to try to specialize them, which currently does not work. Once that is fixed, remove the next 3 lines and uncomment the
-		// previous line.
+
+		// if there is a non-zero conversion cost, ignoring poly cost, then the expression requires conversion.
+		// ignore poly cost for now, since this requires resolution of the cast to infer parameters and this
+		// does not currently work for the reason stated below.
 		Cost tmpCost = convCost;
 		tmpCost.incPoly( -tmpCost.get_polyCost() );
 		if ( tmpCost != Cost::zero ) {
+		// if ( convCost != Cost::zero ) {
 			Type *newType = formalType->clone();
 			env.apply( newType );
@@ -914,9 +914,5 @@
 				thisCost.incSafe( discardedValues );
 				Alternative newAlt( restructureCast( i->expr->clone(), toType ), i->env, i->cost, thisCost );
-				// xxx - this doesn't work at the moment, since inferParameters requires an ApplicationExpr as the alternative.
-				// Once this works, it should be possible to infer parameters on a cast expression and specialize any function.
-
 				inferParameters( needAssertions, haveAssertions, newAlt, openVars, back_inserter( candidates ) );
-				// candidates.emplace_back( std::move( newAlt ) );
 			} // if
 		} // for
@@ -1297,5 +1293,6 @@
 					// count one safe conversion for each value that is thrown away
 					thisCost.incSafe( discardedValues );
-					candidates.push_back( Alternative( new InitExpr( restructureCast( alt.expr->clone(), toType ), initAlt.designation->clone() ), newEnv, alt.cost, thisCost ) );
+					Alternative newAlt( new InitExpr( restructureCast( alt.expr->clone(), toType ), initAlt.designation->clone() ), newEnv, alt.cost, thisCost );
+					inferParameters( needAssertions, haveAssertions, newAlt, openVars, back_inserter( candidates ) );
 				}
 			}
Index: src/ResolvExpr/Resolver.cc
===================================================================
--- src/ResolvExpr/Resolver.cc	(revision 68195a628dc9339c2a4a40f3436aa4bfbcbbefb9)
+++ src/ResolvExpr/Resolver.cc	(revision bb666f649c7489fc5da7103d9f3f6dd470486575)
@@ -593,4 +593,5 @@
 		initExpr->expr = nullptr;
 		std::swap( initExpr->env, newExpr->env );
+		std::swap( initExpr->inferParams, newExpr->inferParams ) ;
 		delete initExpr;
 
