Cache invalid types also

This is a small correction/enhancement to the major performance improvement of caching TypeWithDict for non-class types.  In the prior pull request, caching was done only for valid types.  However, the conditions database also looks up types that are invaild. There is nothing wrong with this, but a default constructed TypeWithDict for an invalid type also needs to be cached.
Please merge this promptly unless there are issues.