Ensure that the post type object is the queried object when a post type has been registered with `has_archive => true`. Ensure it is not stomped when decorated with `tax_query`. Adds unit tests.

Props nacin.
Fixes #18614.


Built from https://develop.svn.wordpress.org/trunk@25291


git-svn-id: http://core.svn.wordpress.org/trunk@25255 1a063a9b-81f0-0310-95a4-ce76da25c4cd