Fix type instability of closures capturing types (2) (#40985)
Instead of closures lowering to `typeof` for the types of captured
fields, this introduces a new function `_typeof_captured_variable` that
returns `Type{T}` if `T` is a type (w/o free typevars).
- replaces/closes #35970
- fixes #23618
---------
Co-authored-by: Takafumi Arakaki <aka.tkf@gmail.com>
Co-authored-by: Shuhei Kadowaki <aviatesk@gmail.com>