Skip to content

Commit

Permalink
inference: callsite conditional argument type refinement
Browse files Browse the repository at this point in the history
- within a callee (i.e. `typeinf_local`), we widen conditional return
  type if it doesn't refine input argument type (for better cache)
- within a caller (i.e. `abstract_call_gf_by_type`), we re-form a
  conditional if needed, which allows us to choose a propagation target
  more appropriately

this commit implements the "pick up" logic within a caller
(i.e. within `abstract_call_gf_by_type`), which allows us to choose a
constraint more appropriately, and now the `Meta.isexpr` case is fixed.
Still there is a limitation of multiple conditional constraint
back-propagation; the following broken test case will explain the future
work.
```julia
is_int_and_int(a, b) = isa(a, Int) && isa(b, Int)
@test_broken Base.return_types((Any,Any)) do a, b
    is_int_and_int(a, b) && return a, b # (a::Int, b::Int) ideally, but (a::Any, b::Int)
    0, 0
end == Any[Tuple{Int,Int}]
```
  • Loading branch information
aviatesk committed Feb 3, 2021
1 parent 7ca6f2b commit 3df027a
Show file tree
Hide file tree
Showing 3 changed files with 210 additions and 87 deletions.
Loading

0 comments on commit 3df027a

Please sign in to comment.