Stereocontrolled cyclofunctionalizations of double bonds through heterocyclic intermediates