So you admit that the "gateway effect" that you hypothesize is correlated to the legality of the "gateway drug". Interesting.
But, legalizing recreational drug A would increase the number of users of drug A, and some of them would go on to drug B despite its illegality.
But if the "gateway effect" is mitigated, it will be at a lower rate than currently and thus increased use of drug A might not cause increased use of drug B, and may in fact lower it?
So your call for marijuana remaining illegal may result in more people addicted to heroin.
I have no idea.
It could be the keeping marijuana illegal may result in less marijuana users which may result in less gateway heroin users.