Yes, BUT:
You CANNOT put the pistol upper on the rifle lower without committing a Federal (and, quite likely state) felony—unless you file a Form 1 with the BATFE to register your rifle lower as a Short Barreled Rifle (SBR) and pay for the $200 tax stamp (if legal in your state).
You can put the rifle upper on your pistol lower, unless your state has a maximum barrel length for a handgun.