The .40 barrel does not fit the 9mm slide.
There are some people who say you can remove metal and make it work, but I have not seen a working "reverse caliber change" on an M&P.
The 9mm barrel is a loose fit in the .40 slide, and seems to work well enough in practice.