def _merge_patches(self):
for patched_item, patched_namespace in self._patch_data_by_canonical_name.values():<EOL><INDENT>patched_item_base_name = self._get_base_name(patched_item.name, patched_namespace.name)<EOL>if patched_item_base_name not in self._item_by_canonical_name:<EOL><INDENT>raise InvalidSpec('<STR_LIT>'.format(<EOL>quote(patched_item.name)), patched_item.lineno, patched_item.path)<EOL><DEDENT>existing_item = self._item_by_canonical_name[patched_item_base_name]<EOL>self._check_patch_type_mismatch(patched_item, existing_item)<EOL>if isinstance(patched_item, (AstStructPatch, AstUnionPatch)):<EOL><INDENT>self._check_field_names_unique(existing_item, patched_item)<EOL>existing_item.fields += patched_item.fields<EOL>self._inject_patched_examples(existing_item, patched_item)<EOL><DEDENT>else:<EOL><INDENT>raise AssertionError('<STR_LIT>'.format(<EOL>patched_item.__class__.__name__))<EOL><DEDENT><DEDENT>
Injects object patches into their original object definitions.