Imagine a rect of width=1 and height=1. That means exactly one point should be inside.
With your changes, this rectangle would contain 4 pixels, even though it’s just 1 pixel wide and 1 pixel high.
There is some logic to the current implementation.
That makes sense, but in that case getRight() should return pos.x + w - 1 rather than pos.x + w. Possibly the bug is in getRight() and getBottom() rather than contains(). Or else the documentation is wrong and getRight() is actually supposed to be 1 pixel outside the rightmost pixel, a la Windows APIs like GetWindowRect().
So if pos.x was, say, three, and you called setRight(3), the rectangle’s width would get set to zero, causing contains() to always return false. This seems incorrect unless setRight() is actually supposed to be setting one beyond the rightmost pixel and a rectangle with left = right is supposed to be zero pixels wide. In that case, it’s just that the documentation could stand to be made more clear.
So the consistent view would be to imagine it as two ranges of X and Y, where the lower bound is included and the upper bound excluded.
Just a word of warning, even if it is found to be inconsistent with the expectation, changing it will break almost every project, beginning with Component…