https://github.com/JuliaLang/julia
Revision bbe91dbfaa27dae35cce2b27ef68cb12ff6a1aba authored by Shuhei Kadowaki on 11 October 2021, 05:47:03 UTC, committed by KristofferC on 08 November 2021, 09:15:05 UTC
During working on the incoming lattice overhaul, I found it's quite
confusing that `TypeVar` and `Vararg` can appear in the same context
as valid `Type` objects as well as extended lattice elements.
Since it usually needs special cases to operate on `TypeVar` and `Vararg`
(e.g. they can not be used in subtyping as an obvious example), I believe
it would be great avoid bugs and catch logic errors in the future development
if we separate contexts where they can appear from ones where `Type`
objects and extended lattice elements are expected.

So this commit:
- tries to separate their context, e.g. now `TypeVar` and `Vararg` should
  not be used in `_limit_type_size`, which is supposed to return `Type`,
  but they should be handled its helper function `__limit_type_size`
- makes sure `tfunc`s don't return `TypeVar`s and `TypeVar` never spills
  into the abstract state
- makes sure `widenconst` are not called on `TypeVar` and `Vararg`,
  and now `widenconst` is ensured to return `Type` always
- and does other general refactors

(cherry picked from commit d60f92cd3a92cd12cae55893e55e6d9e14b0052e)
1 parent 9723f82
History
Tip revision: bbe91dbfaa27dae35cce2b27ef68cb12ff6a1aba authored by Shuhei Kadowaki on 11 October 2021, 05:47:03 UTC
inference: improve `TypeVar`/`Vararg` handling
Tip revision: bbe91db

back to top