determine the match shorthand target early.

This is a backport of #9361 to fix #7554.