Index: wp-includes/query.php
===================================================================
--- wp-includes/query.php	(revision 22717)
+++ wp-includes/query.php	(working copy)
@@ -2224,8 +2224,12 @@
 				$post_type = array();
 				$taxonomies = wp_list_pluck( $this->tax_query->queries, 'taxonomy' );
 				foreach ( get_post_types( array( 'exclude_from_search' => false ) ) as $pt ) {
-					if ( array_intersect( $taxonomies, get_object_taxonomies( $pt ) ) )
-						$post_type[] = $pt;
+					if ( $pt === 'attachment' )
+						if ( array_intersect( $taxonomies, get_taxonomies_for_attachments() ) )
+							$post_type[] = $pt;
+					else
+						if ( array_intersect( $taxonomies, get_object_taxonomies( $pt ) ) )
+							$post_type[] = $pt;
 				}
 				if ( ! $post_type )
 					$post_type = 'any';
