Not legal, unless the extension is continuously rifled from the chamber to the muzzle. In other words, a sleeved GI barrel where the sleeve is 18.5 inches or longer would be legal, while a 0.5" stub welded or soldered to a GI barrel is not.
Back in the day, the RCMP looked the other way for a while and people were sweating on a piece of pipe to the muzzle to get to 18.5". Then they ruled it had to be rifled, so some people would get a piece of 9mm rifled barrel and sweat that onto the end. This was then ruled against, and finally they settled on continuous rifling. I can;t remember the details, but I believe there was a court precedent.
Remember, the whole 18.5 thing was originally selected specifically to restrict the M1 carbine. There were too many in-country to prohibit it without political fallout, and it didn;t fit the "evil black rifle" mould. It had no pistol grip and most had no bayonet lug, but there were a couple famous M1 carbine incidents, the best known being when Patty Hearst used one to hold up the Sunset District branch of the Hibernia Bank at 1450 Noriega Street in San Francisco. The "restricted by name" thing was not yet invented for the AR, that came later after it was initially selected to be prohibited, but the DCRA protested the draft regulations when published in Hansard.
Bottom line, is you need a barrel that was either sleeved completely with an 18.5" or longer inner barrel, or a barrel manufactured 18.5" or longer.