Index: src/Tuples/TupleExpansion.cc
===================================================================
--- src/Tuples/TupleExpansion.cc	(revision c5f3c68c3e861030ba705e8dae111f3bea0870ed)
+++ src/Tuples/TupleExpansion.cc	(revision 027c496d766e376420753a18fca90ddcabe467a9)
@@ -315,15 +315,14 @@
 	namespace {
 		/// determines if impurity (read: side-effects) may exist in a piece of code. Currently gives a very crude approximation, wherein any function call expression means the code may be impure
-		class ImpurityDetector : public Visitor {
-		public:
+		struct ImpurityDetector : public WithShortCircuiting {
 			ImpurityDetector( bool ignoreUnique ) : ignoreUnique( ignoreUnique ) {}
 
-			typedef Visitor Parent;
-			virtual void visit( ApplicationExpr * appExpr ) {
+			void previsit( ApplicationExpr * appExpr ) {
+				visit_children = false;
 				if ( DeclarationWithType * function = InitTweak::getFunction( appExpr ) ) {
 					if ( function->get_linkage() == LinkageSpec::Intrinsic ) {
 						if ( function->get_name() == "*?" || function->get_name() == "?[?]" ) {
 							// intrinsic dereference, subscript are pure, but need to recursively look for impurity
-							Parent::visit( appExpr );
+							visit_children = true;
 							return;
 						}
@@ -332,13 +331,13 @@
 				maybeImpure = true;
 			}
-			virtual void visit( UntypedExpr * ) { maybeImpure = true; }
-			virtual void visit( UniqueExpr * unq ) {
+			void previsit( UntypedExpr * ) { maybeImpure = true; visit_children = false; }
+			void previsit( UniqueExpr * ) {
 				if ( ignoreUnique ) {
 					// bottom out at unique expression.
 					// The existence of a unique expression doesn't change the purity of an expression.
 					// That is, even if the wrapped expression is impure, the wrapper protects the rest of the expression.
+					visit_children = false;
 					return;
 				}
-				maybeAccept( unq->expr, *this );
 			}
 
@@ -349,13 +348,13 @@
 
 	bool maybeImpure( Expression * expr ) {
-		ImpurityDetector detector( false );
+		PassVisitor<ImpurityDetector> detector( false );
 		expr->accept( detector );
-		return detector.maybeImpure;
+		return detector.pass.maybeImpure;
 	}
 
 	bool maybeImpureIgnoreUnique( Expression * expr ) {
-		ImpurityDetector detector( true );
+		PassVisitor<ImpurityDetector> detector( true );
 		expr->accept( detector );
-		return detector.maybeImpure;
+		return detector.pass.maybeImpure;
 	}
 } // namespace Tuples
