A man convicted of defilement and sentenced to 10 years in prison has been freed after the High Court ruled prosecutors failed to prove the complainant was under 18 at the time.