Skip to content

Commit

Permalink
improve instanceof_tfunc to take declared parameter bounds into acc…
Browse files Browse the repository at this point in the history
…ount (#33472)
  • Loading branch information
JeffBezanson authored and Keno committed Oct 5, 2019
1 parent 0725e0e commit 7466d11
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
8 changes: 7 additions & 1 deletion base/compiler/tfuncs.jl
Expand Up @@ -78,7 +78,13 @@ function instanceof_tfunc(@nospecialize(t))
elseif isa(t, UnionAll)
t′ = unwrap_unionall(t)
t′′, isexact = instanceof_tfunc(t′)
return rewrap_unionall(t′′, t), isexact
tr = rewrap_unionall(t′′, t)
if t′′ isa DataType && !has_free_typevars(tr)
# a real instance must be within the declared bounds of the type,
# so we can intersect with the original wrapper.
tr = typeintersect(tr, t′′.name.wrapper)
end
return tr, isexact
elseif isa(t, Union)
ta, isexact_a = instanceof_tfunc(t.a)
tb, isexact_b = instanceof_tfunc(t.b)
Expand Down
3 changes: 3 additions & 0 deletions test/compiler/inference.jl
Expand Up @@ -2442,3 +2442,6 @@ f31974(n::Int) = f31974(1:n)
# This query hangs if type inference improperly attempts to const prop
# call cycles.
@test code_typed(f31974, Tuple{Int}) !== nothing

f_overly_abstract_complex() = Complex(Ref{Number}(1)[])
@test Base.return_types(f_overly_abstract_complex, Tuple{}) == [Complex]

2 comments on commit 7466d11

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Executing the daily benchmark build, I will reply here when finished:

@nanosoldier runbenchmarks(ALL, isdaily = true)

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your benchmark job has completed - possible performance regressions were detected. A full report can be found here. cc @ararslan

Please sign in to comment.