Index: src/GenPoly/InstantiateGeneric.cc
===================================================================
--- src/GenPoly/InstantiateGeneric.cc	(revision 4e7a4e6f5a54d4c358298acebe5d7a782f0fc9d5)
+++ src/GenPoly/InstantiateGeneric.cc	(revision 55d6e8de222270bc01df132ae38161e27cfebe86)
@@ -453,13 +453,4 @@
 			return false;
 		}
-
-		AggregateDecl * getAggr( Type * t ) {
-			if ( StructInstType * inst = dynamic_cast< StructInstType * >( t ) ) {
-				return inst->baseStruct;
-			} else if ( UnionInstType * inst = dynamic_cast< UnionInstType * >( t ) ) {
-				return inst->baseUnion;
-			}
-			assertf( false, "Non-aggregate type: %s", toString( t ).c_str() );
-		}
 	}
 
@@ -469,5 +460,5 @@
 		if ( isGenericType( memberExpr->aggregate->result ) ) {
 			// find the location of the member
-			AggregateDecl * aggr = getAggr( memberExpr->aggregate->result );
+			AggregateDecl * aggr = memberExpr->aggregate->result->getAggr();
 			std::list< Declaration * > & members = aggr->members;
 			memberIndex = std::distance( members.begin(), std::find( members.begin(), members.end(), memberExpr->member ) );
@@ -479,5 +470,5 @@
 		if ( memberIndex != -1 ) {
 			// using the location from the generic type, find the member in the instantiation and rebuild the member expression
-			AggregateDecl * aggr = getAggr( memberExpr->aggregate->result );
+			AggregateDecl * aggr = memberExpr->aggregate->result->getAggr();
 			assertf( memberIndex < (int)aggr->members.size(), "Instantiation somehow has fewer members than the generic type." );
 			Declaration * member = *std::next( aggr->members.begin(), memberIndex );
