You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
inference: enable constant propagation for invoked calls, fixes#41024 (#41383)
* inference: enable constant propagation for `invoke`d calls, fixes#41024
Especially useful for defining mixins with typed interface fields, e.g.
```julia
abstract type AbstractInterface end # mixin, which expects common field `x::Int`
function Base.getproperty(x::AbstractInterface, sym::Symbol)
if sym === :x
return getfield(x, sym)::Int # inferred field
else
return getfield(x, sym) # fallback
end
end
abstract type AbstractInterfaceExtended <: AbstractInterface end # extended mixin, which expects additional common field `y::Rational{Int}`
function Base.getproperty(x::AbstractInterfaceExtended, sym::Symbol)
if sym === :y
return getfield(x, sym)::Rational{Int}
end
return Base.@invoke getproperty(x::AbstractInterface, sym::Symbol)
end
```
As a bonus, inliner is able to use `InferenceResult` as a fast inlining
pass for constant-prop'ed `invoke`s
* improve compile-time latency
* Update base/compiler/abstractinterpretation.jl
* Update base/compiler/abstractinterpretation.jl
0 commit comments