China is foolish here for several reasons.
But from a pure economic perspective, Hong Kong is the goose that laid the golden egg for China. Its growth depends upon Hong Kong's international financial clout. And Hong Kong's role as a financial centre depends upon freedom and the rle of law. Take that away and it is, well, just anther piece of an autocratic state in which the investment incentives are relatively narrow.