I wonder if there are huge advances to be made in suppressor technology? Other than the noise, guns are basically perfect in their intended function. I guess you could try to further reduce recoil.
There have been some pretty fascinating experimental weapons over the the years. For example, the H&K G11 [0] used caseless ammunition. The potential advantages of that are no need to eject a spent casing and a soldier can carry more of it since it weighs less.
Oh, there's a lot more stuff that can be done to guns:
1) improve aim: embed wind and angle sensors, possibly even battlefield intel (position, weather, land layout) to account for any drift that might impact the bullet. Also, auto-fire if a designated target is in the crosshair (train the AI on human faces, combine with the previous sensoring). I would not be surprised if this technology will be developed rather sooner than later with armed robots, and then made smaller until it fits in a gun or at least a rifle.
2) improve/rethink propulsion. Right now almost all guns operate by some form of bullet in a casing with explosive propellant (excluding the rare caseless guns and co2/pressured gas sports guns). Railguns are already a thing at "ship scale", it will be only a matter of time until it gets scaled down to hand-held guns.
3) improve projectiles. Right now bullets are dumb pieces of metal. Why not have active bullets (e.g. subminiature rockets) or bullets laced with poisons so that even a scrape kills in the end?
4) improve... guns themselves, as a concept - think laser guns a la Star Trek, highly focused microwave, sound or other energy.
In the end humanity will always improve ways to kill each other, and all the concepts are already there in sci-fi (and in the case of poison bullets, the Russians made it a reality with the Markov murder).
I think those are all really great ideas for new inventions, some of which might eventually replace firearms. But I still think firearms are basically topped out. Anything else done to them complicates them more than it improves them.
[0] https://en.wikipedia.org/wiki/Heckler_%26_Koch_G11