Fix inheritance mapping when extending documents

This PR fixes #927.