Fix the ordering of `unsafe` and `extern` in methods

Fixes #19398.