Index: src/GenPoly/BoxNew.cpp
===================================================================
--- src/GenPoly/BoxNew.cpp	(revision 61e5d998091dfd12ea60e1fee02afb30670df0f3)
+++ src/GenPoly/BoxNew.cpp	(revision 4d2d7e27e4d8dc2800e43c5566536e0edfca4b99)
@@ -376,6 +376,4 @@
 	ast::Expr const * postvisit( ast::AddressExpr const * expr );
 	ast::ReturnStmt const * previsit( ast::ReturnStmt const * stmt );
-	void previsit( ast::PointerType const * type );
-	void previsit( ast::FunctionType const * type );
 
 	void beginScope();
@@ -553,12 +551,11 @@
 
 ast::FunctionDecl const * CallAdapter::previsit( ast::FunctionDecl const * decl ) {
+	// Prevent type declaration information from leaking out.
+	GuardScope( scopeTypeVars );
+
 	if ( nullptr == decl->stmts ) {
-		// This may keep TypeDecls we don't ever want from sneaking in.
-		// Not visiting child nodes might just be faster.
-		GuardScope( scopeTypeVars );
 		return decl;
 	}
 
-	GuardScope( scopeTypeVars );
 	GuardValue( retval );
 
@@ -687,8 +684,4 @@
 
 	assert( typeSubs );
-	ast::Type const * concRetType = replaceWithConcrete( dynRetType, *typeSubs );
-	// Used to use dynRetType instead of concRetType; this changed so that
-	// the correct type parameters are passed for return types (it should be
-	// the concrete type's parameters, not the formal type's).
 	ast::vector<ast::Expr>::iterator argIt =
 		passTypeVars( mutExpr, function );
@@ -768,14 +761,4 @@
 	}
 	return stmt;
-}
-
-void CallAdapter::previsit( ast::PointerType const * type ) {
-	GuardScope( scopeTypeVars );
-	makeTypeVarMap( type, scopeTypeVars );
-}
-
-void CallAdapter::previsit( ast::FunctionType const * type ) {
-	GuardScope( scopeTypeVars );
-	makeTypeVarMap( type, scopeTypeVars );
 }
 
@@ -1595,5 +1578,4 @@
 	PolyGenericCalculator();
 
-	void previsit( ast::ObjectDecl const * decl );
 	void previsit( ast::FunctionDecl const * decl );
 	void previsit( ast::TypedefDecl const * decl );
@@ -1602,6 +1584,4 @@
 	ast::StructDecl const * previsit( ast::StructDecl const * decl );
 	ast::UnionDecl const * previsit( ast::UnionDecl const * decl );
-	void previsit( ast::PointerType const * type );
-	void previsit( ast::FunctionType const * type );
 	ast::DeclStmt const * previsit( ast::DeclStmt const * stmt );
 	ast::Expr const * postvisit( ast::MemberExpr const * expr );
@@ -1639,6 +1619,4 @@
 	/// adding the type variables from the provided type.
 	void beginTypeScope( ast::Type const * );
-	/// Enters a new scope for known layouts and offsets, and queues exit calls.
-	void beginGenericScope();
 
 	/// Set of generic type layouts known in the current scope,
@@ -1652,6 +1630,4 @@
 	/// If the argument of an AddressExpr is MemberExpr, it is stored here.
 	ast::MemberExpr const * addrMember = nullptr;
-	/// Used to avoid recursing too deep in type declarations.
-	bool expect_func_type = false;
 };
 
@@ -1675,10 +1651,6 @@
 }
 
-void PolyGenericCalculator::previsit( ast::ObjectDecl const * decl ) {
-	beginTypeScope( decl->type );
-}
-
 void PolyGenericCalculator::previsit( ast::FunctionDecl const * decl ) {
-	beginGenericScope();
+	GuardScope( *this );
 	beginTypeScope( decl->type );
 }
@@ -1742,21 +1714,4 @@
 }
 
-void PolyGenericCalculator::previsit( ast::PointerType const * type ) {
-	beginTypeScope( type );
-}
-
-void PolyGenericCalculator::previsit( ast::FunctionType const * type ) {
-	beginTypeScope( type );
-
-	GuardValue( expect_func_type );
-	GuardScope( *this );
-
-	// The other functions type we will see in this scope are probably
-	// function parameters they don't help us with the layout and offsets so
-	// don't mark them as known in this scope.
-	expect_func_type = false;
-}
-
-//void PolyGenericCalculator::previsit( ast::DeclStmt const * stmt ) {
 ast::DeclStmt const * PolyGenericCalculator::previsit( ast::DeclStmt const * stmt ) {
 	ast::ObjectDecl const * decl = stmt->decl.as<ast::ObjectDecl>();
@@ -2248,14 +2203,6 @@
 }
 
-void PolyGenericCalculator::beginGenericScope() {
-	GuardScope( *this );
-	// We expect the first function type see to be the type relating to this
-	// scope but any further type is probably some unrelated function pointer
-	// keep track of whrich is the first.
-	GuardValue( expect_func_type ) = true;
-}
-
 // --------------------------------------------------------------------------
-/// No common theme found.
+/// Removes unneeded or incorrect type information.
 /// * Replaces initialization of polymorphic values with alloca.
 /// * Replaces declaration of dtype/ftype with appropriate void expression.
