Skip to content

Commit

Permalink
improve partial opaque inference (#45782)
Browse files Browse the repository at this point in the history
improve opaqueclosure inference 
#42831 started calling `tmeet` in abstractinterpretation of `:new` which meant that we now need to be able to infer it.
Co-authored-by: Keno Fischer <keno@juliacomputing.com>
  • Loading branch information
oscardssmith authored Jun 23, 2022
1 parent 4873773 commit aa17702
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
9 changes: 9 additions & 0 deletions base/compiler/typelattice.jl
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,15 @@ function tmeet(@nospecialize(v), @nospecialize(t::Type))
end
end
return tuple_tfunc(new_fields)
elseif isa(v, PartialOpaque)
has_free_typevars(t) && return v
widev = widenconst(v)
if widev <: t
return v
end
ti = typeintersect(widev, t)
valid_as_lattice(ti) || return Bottom
return PartialOpaque(ti, v.env, v.parent, v.source)
elseif isa(v, Conditional)
if !(Bool <: t)
return Bottom
Expand Down
6 changes: 6 additions & 0 deletions test/compiler/inference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4250,3 +4250,9 @@ let # NOTE make sure this toplevel chunk doesn't contain any local binding
while xcond end
end
@test !xcond

struct Issue45780
oc::Core.OpaqueClosure{Tuple{}}
end
f45780() = Val{Issue45780(@Base.Experimental.opaque ()->1).oc()}()
@test (@inferred f45780()) == Val{1}()

2 comments on commit aa17702

@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 package evaluation, I will reply here when finished:

@nanosoldier runtests(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 package evaluation job has completed - possible new issues were detected. A full report can be found here.

Please sign in to comment.