The reason that's illegal isn't because of how you extended it, but rather it's because you cut the barrel off in order to extend it. The moment you cut the barrel you illegally create an unregistered SBS. Fixing it afterward by extending the barrel permanently doesn't erase the fact that you already created an illegal SBS. There is a legal way to do this that involves sending the damaged barrel out to be extended so possession is no longer a factor when it's cut during the repair.
Sorry I just noticed someone else beat me to it.