This hack for Sonic 2 is called Portal Gun in Sonic 2, and it modifies the game so that Sonic may use the Portal Gun.
As a result, you will be able to restart the game by blasting portals, and the game will continue to follow the same guidelines as Portal (entering a portal to exit through the other)