Erythroblastosis fetalis may develop when: