Index: src/GenPoly/SpecializeNew.cpp
===================================================================
--- src/GenPoly/SpecializeNew.cpp	(revision 52a5262e330888e3eb665835b9682e7130ded8a1)
+++ src/GenPoly/SpecializeNew.cpp	(revision d85141f3646aaab49810e9f41dfae72e33616e5d)
@@ -81,24 +81,20 @@
 }
 
-// The number of elements in a type if it is a flattened tuple.
-size_t flatTupleSize( const ast::Type * type ) {
-	if ( auto tuple = dynamic_cast<const ast::TupleType *>( type ) ) {
-		size_t sum = 0;
-		for ( auto t : *tuple ) {
-			sum += flatTupleSize( t );
-		}
-		return sum;
-	} else {
-		return 1;
-	}
+// The number of elements in a list, if all tuples had been flattened.
+size_t flatTypeListSize( const std::vector<ast::ptr<ast::Type>> & types ) {
+	size_t sum = 0;
+	for ( const ast::ptr<ast::Type> & type : types ) {
+		if ( const ast::TupleType * tuple = type.as<ast::TupleType>() ) {
+			sum += flatTypeListSize( tuple->types );
+		} else {
+			sum += 1;
+		}
+	}
+	return sum;
 }
 
 // Find the total number of components in a parameter list.
 size_t functionParameterSize( const ast::FunctionType * type ) {
-	size_t sum = 0;
-	for ( auto param : type->params ) {
-		sum += flatTupleSize( param );
-	}
-	return sum;
+	return flatTypeListSize( type->params );
 }
 
