If authorities *unlawfully* discover that you committed a crime?

Simfish InquilineKea asked: Then will you be charged with the crime if such crime is reported to authorities?
Say you commit a victimless crime that is a felony (say, possessing Schedule I drugs) and you’re not on a rehabilitation program. You disclose that you’ve committed it to your psychologist. Your psychologist, by law, cannot disclose information [...]