Forbid extern statics from appearing in patterns

Fixes #16149.