So I took my G18 and my G31 (I did not have a G17, but the frames of G17 and G31 are the same) out.
First I tried if the G18 slide fits on the G31 frame.
It does not! The G31 upper however fits on the G18 frame, but dry firing it, it did not sound right! I did not test shoot it, but think it would work.
I took the frames apart and compared the parts.
The picture below shows the differences of the G18 frame to the other small Glock frames.
1.The G18 frames/slides are smaller then the other frames.
2.The rear rail is longer as indicated in the picture below.
3.Also marked by the arrow, there is a cut out in the frame on the G18.
The rest is the same, including the block and I am sure that the parts are 100% exchangeable.