work around some closure capture boxing inference issues in loading (#59367)
The only method of the `__require_prelocked` function in `Base` gets
compiled with bad inference for two variables, `path` and `reasons`,
which get pessimistically boxed (and inferred as `Any`), even though
both of them are only assigned to once across both the method and the
closure within (neither is assigned to within the closure).
My guess for what causes this would be either of these, or the
combination:
* (mis)use of GOTO
* `try`-`catch`
The least demanding way to work around the issue is adding a `let`
around the closure, as advised in the Performance tips. That is what
this change does.
This change should fix several bad inference results within method
instances such as `__require_prelocked(::PkgId, ::Nothing)` and
`__require_prelocked(::PkgId, ::String)`. Consequently, the sysimage
should become less vulnerable to invalidation happening when loading
certain packages.