We just had a question about what happens to convicts if a law is repealed. However, that question's example of homosexual behavior wasn't decriminalized in the US by legislative action, but rather by the Supreme Court ruling the laws unconstitutional in Lawrence v. Texas.
Court decisions certainly do have some retroactive effect -- even though Lawrence's actions occurred before the ruling, he couldn't be sent to jail for them. So if you were convicted under some law but that law was later struck down in a different case, do you go free? Does it matter what stage the trial was at (e.g. final judgment with appeals exhausted vs. on appeal vs. in trial court)? Does it matter if you had challenged the law's constitutionality?
Please cite answers.