-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Closed
Labels
compiler:inferenceType inferenceType inference
Description
Apologies, I'm sure this must have been reported before but a search didn't pick it up.
There appear to be cases where it would be "easy" to preserve bounds on abstract types. One that comes up a lot in my invalidation-squashing is Iterators.Stateful
:
julia> code_typed(Iterators.Stateful, (AbstractString,))
1-element Array{Any,1}:
CodeInfo(
1 ─ %1 = invoke Base.Iterators.approx_iter_type($(Expr(:static_parameter, 1))::Type{T} where T)::Type
│ %2 = Core.apply_type(Base.Iterators.Stateful, $(Expr(:static_parameter, 1)), %1)::Type{Base.Iterators.Stateful{_A,_B}} where _B where _A
│ %3 = Base.convert($(Expr(:static_parameter, 1)), itr)::Any
│ %4 = Core.fieldtype(%2, 2)::Type{var"#s428"} where var"#s428"<:(Union{Nothing, _B} where _B)
│ %5 = Base.Iterators.iterate(itr)::Any
│ Core.typeassert(%5, %1)::Any
│ %7 = Base.convert(%4, %5)::Any
│ %8 = %new(%2, %3, %7, 0)::Base.Iterators.Stateful{_A,_B} where _B where _A
└── return %8
) => Base.Iterators.Stateful{_A,_B} where _B where _A
Given the definition
Lines 1243 to 1246 in d762e8c
@inline function Stateful(itr::T) where {T} | |
VS = approx_iter_type(T) | |
return new{T, VS}(itr, iterate(itr)::VS, 0) | |
end |
_A<:AbstractString
.Metadata
Metadata
Assignees
Labels
compiler:inferenceType inferenceType inference