code: def _check_patch_type_mismatch(self, patched_item, existing_item):
          
          def raise_mismatch_error(patched_item, existing_item, data_type_name):
              error_msg = ('Type mismatch. Patch {} corresponds to pre-existing '
                  'data_type {} ({}:{}) that has type other than {}.')
              raise InvalidSpec(error_msg.format(
                  quote(patched_item.name),
                  quote(existing_item.name),
                  existing_item.path,
                  existing_item.lineno,
                  quote(data_type_name)), patched_item.lineno, patched_item.path)
  
          if isinstance(patched_item, AstStructPatch):
              if not isinstance(existing_item, AstStructDef):
                  raise_mismatch_error(patched_item, existing_item, 'struct')
          elif isinstance(patched_item, AstUnionPatch):
              if not isinstance(existing_item, AstUnionDef):
                  raise_mismatch_error(patched_item, existing_item, 'union')
              else:
                  if existing_item.closed != patched_item.closed:
                      raise_mismatch_error(
                          patched_item, existing_item,
                          'union_closed' if existing_item.closed else 'union')
          else:
              raise AssertionError(
                  'Unknown Patch Object Type {}'.format(patched_item.__class__.__name__))
docs: Enforces that each patch has a corresponding, already-defined data type.