Program: 23557
Project: 23557
Buggy source:
public org.hl7.fhir.dstu2.model.StructureDefinition convertStructureDefinition(org.hl7.fhir.dstu3.model.StructureDefinition src) throws FHIRException {
  if (src == null)   return null;
  org.hl7.fhir.dstu2.model.StructureDefinition tgt=new org.hl7.fhir.dstu2.model.StructureDefinition();
  copyDomainResource(src,tgt);
  tgt.setUrl(src.getUrl());
  for (  org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())   tgt.addIdentifier(convertIdentifier(t));
  tgt.setVersion(src.getVersion());
  tgt.setName(src.getName());
  tgt.setDisplay(src.getDisplay());
  tgt.setStatus(convertConformanceResourceStatus(src.getStatus()));
  tgt.setExperimental(src.getExperimental());
  tgt.setPublisher(src.getPublisher());
  for (  org.hl7.fhir.dstu3.model.StructureDefinition.StructureDefinitionContactComponent t : src.getContact())   tgt.addContact(convertStructureDefinitionContactComponent(t));
  tgt.setDate(src.getDate());
  tgt.setDescription(src.getDescription());
  for (  org.hl7.fhir.dstu3.model.CodeableConcept t : src.getUseContext())   tgt.addUseContext(convertCodeableConcept(t));
  tgt.setRequirements(src.getRequirements());
  tgt.setCopyright(src.getCopyright());
  for (  org.hl7.fhir.dstu3.model.Coding t : src.getCode())   tgt.addCode(convertCoding(t));
  tgt.setFhirVersion(src.getFhirVersion());
  for (  org.hl7.fhir.dstu3.model.StructureDefinition.StructureDefinitionMappingComponent t : src.getMapping())   tgt.addMapping(convertStructureDefinitionMappingComponent(t));
  tgt.setKind(convertStructureDefinitionKind(src.getKind()));
  tgt.setAbstract(src.getAbstract());
  tgt.setContextType(convertExtensionContext(src.getContextType()));
  for (  org.hl7.fhir.dstu3.model.StringType t : src.getContext())   tgt.addContext(t.getValue());
  tgt.setConstrainedType(src.getType());
  tgt.setBase(src.getBaseDefinition());
  tgt.setSnapshot(convertStructureDefinitionSnapshotComponent(src.getSnapshot()));
  tgt.setDifferential(convertStructureDefinitionDifferentialComponent(src.getDifferential()));
  if (tgt.hasBase()) {
    if (tgt.hasDifferential())     tgt.getDifferential().getElement().get(0).addType().setCode(tail(tgt.getBase()));
    if (tgt.hasSnapshot())     tgt.getSnapshot().getElement().get(0).addType().setCode(tail(tgt.getBase()));
  }
  return tgt;
}

Fixed version (ground truth):
public org.hl7.fhir.dstu2.model.StructureDefinition convertStructureDefinition(org.hl7.fhir.dstu3.model.StructureDefinition src) throws FHIRException {
  if (src == null || src.isEmpty())   return null;
  org.hl7.fhir.dstu2.model.StructureDefinition tgt=new org.hl7.fhir.dstu2.model.StructureDefinition();
  copyDomainResource(src,tgt);
  tgt.setUrl(src.getUrl());
  for (  org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())   tgt.addIdentifier(convertIdentifier(t));
  tgt.setVersion(src.getVersion());
  tgt.setName(src.getName());
  tgt.setDisplay(src.getDisplay());
  tgt.setStatus(convertConformanceResourceStatus(src.getStatus()));
  tgt.setExperimental(src.getExperimental());
  tgt.setPublisher(src.getPublisher());
  for (  org.hl7.fhir.dstu3.model.StructureDefinition.StructureDefinitionContactComponent t : src.getContact())   tgt.addContact(convertStructureDefinitionContactComponent(t));
  tgt.setDate(src.getDate());
  tgt.setDescription(src.getDescription());
  for (  org.hl7.fhir.dstu3.model.CodeableConcept t : src.getUseContext())   tgt.addUseContext(convertCodeableConcept(t));
  tgt.setRequirements(src.getRequirements());
  tgt.setCopyright(src.getCopyright());
  for (  org.hl7.fhir.dstu3.model.Coding t : src.getCode())   tgt.addCode(convertCoding(t));
  tgt.setFhirVersion(src.getFhirVersion());
  for (  org.hl7.fhir.dstu3.model.StructureDefinition.StructureDefinitionMappingComponent t : src.getMapping())   tgt.addMapping(convertStructureDefinitionMappingComponent(t));
  tgt.setKind(convertStructureDefinitionKind(src.getKind()));
  tgt.setAbstract(src.getAbstract());
  tgt.setContextType(convertExtensionContext(src.getContextType()));
  for (  org.hl7.fhir.dstu3.model.StringType t : src.getContext())   tgt.addContext(t.getValue());
  tgt.setConstrainedType(src.getType());
  tgt.setBase(src.getBaseDefinition());
  tgt.setSnapshot(convertStructureDefinitionSnapshotComponent(src.getSnapshot()));
  tgt.setDifferential(convertStructureDefinitionDifferentialComponent(src.getDifferential()));
  if (tgt.hasBase()) {
    if (tgt.hasDifferential())     tgt.getDifferential().getElement().get(0).addType().setCode(tail(tgt.getBase()));
    if (tgt.hasSnapshot())     tgt.getSnapshot().getElement().get(0).addType().setCode(tail(tgt.getBase()));
  }
  return tgt;
}