Index: src/ResolvExpr/Unify.cc
===================================================================
--- src/ResolvExpr/Unify.cc	(revision 7e23d0abbb6eaec5182292ffd1c2eb05e1348044)
+++ src/ResolvExpr/Unify.cc	(revision f5234f377ada7d47d16f2cf07778a4ca2e416546)
@@ -508,30 +508,21 @@
 		handleRefType( inst, other );
 		if ( ! result ) return;
-		// Check that parameters of type unify, if any
+		// Check that parameters of types unify, if any
 		std::list< Expression* > params = inst->get_parameters();
-		if ( ! params.empty() ) {
-			std::list< TypeDecl* > *baseParams = inst->get_baseParameters();
-			if ( ! baseParams ) {
+		std::list< Expression* > otherParams = ((RefType*)other)->get_parameters();
+
+		std::list< Expression* >::const_iterator it = params.begin(), jt = otherParams.begin();
+		for ( ; it != params.end() && jt != otherParams.end(); ++it, ++jt ) {
+			TypeExpr *param = dynamic_cast< TypeExpr* >(*it);
+			assert(param && "Aggregate parameters should be type expressions");
+			TypeExpr *otherParam = dynamic_cast< TypeExpr* >(*jt);
+			assert(otherParam && "Aggregate parameters should be type expressions");
+
+			if ( ! unifyExact( param->get_type(), otherParam->get_type(), env, needAssertions, haveAssertions, openVars, WidenMode(false, false), indexer ) ) {
 				result = false;
 				return;
 			}
-			std::list< Expression* >::const_iterator it = params.begin();
-			std::list< TypeDecl* >::const_iterator baseIt = baseParams->begin();
-			while ( it != params.end() && baseIt != baseParams->end()) {
-				TypeExpr *param = dynamic_cast< TypeExpr* >(*it);
-				assert(param && "Aggregate parameters should be type expressions");
-				TypeInstType baseType(Type::Qualifiers(), (*baseIt)->get_name(), *baseIt);
-				if ( ! unifyExact( param->get_type(), &baseType, env, needAssertions, haveAssertions, openVars, WidenMode(false, false), indexer ) ) {
-					result = false;
-					return;
-				}
-				
-				++it;
-				++baseIt;
-			}
-			if ( it != params.end() || baseIt != baseParams->end() ) {
-				result = false;
-			}
 		}
+		result = ( it == params.end() && jt == otherParams.end() );
 	}
 
