Skip to content

Commit

Permalink
inference: Don't try to infer optimized opaque_closure (#56557)
Browse files Browse the repository at this point in the history
We don't have frontend syntax for it, but there is a use case for having
`:new_opaque_closure` take an OC constructed from an optimized
OpaqueClosure (and just replacing the capture environment). In this
case, there is nothing inference can do to introspect into the opaque
closure, so it just needs to bail out early.
  • Loading branch information
Keno authored Nov 14, 2024
1 parent 2e7e3ed commit d99d569
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions Compiler/src/abstractinterpretation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2633,6 +2633,14 @@ function abstract_call_opaque_closure(interp::AbstractInterpreter,
ocsig = rewrap_unionall(Tuple{Tuple, ocargsig′.parameters...}, ocargsig)
hasintersect(sig, ocsig) || return Future(CallMeta(Union{}, Union{MethodError,TypeError}, EFFECTS_THROWS, NoCallInfo()))
ocmethod = closure.source::Method
if !isdefined(ocmethod, :source)
# This opaque closure was created from optimized source. We cannot infer it further.
ocrt = rewrap_unionall((unwrap_unionall(tt)::DataType).parameters[2], tt)
if isa(ocrt, DataType)
return Future(CallMeta(ocrt, Any, Effects(), NoCallInfo()))
end
return Future(CallMeta(Any, Any, Effects(), NoCallInfo()))
end
match = MethodMatch(sig, Core.svec(), ocmethod, sig <: ocsig)
mresult = abstract_call_method(interp, ocmethod, sig, Core.svec(), false, si, sv)
ocsig_box = Core.Box(ocsig)
Expand Down
2 changes: 1 addition & 1 deletion Compiler/src/stmtinfo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ allow the optimizer to rewrite the return type parameter of the `OpaqueClosure`
struct OpaqueClosureCreateInfo <: CallInfo
unspec::CallMeta
function OpaqueClosureCreateInfo(unspec::CallMeta)
@assert isa(unspec.info, OpaqueClosureCallInfo)
@assert isa(unspec.info, Union{OpaqueClosureCallInfo, NoCallInfo})
return new(unspec)
end
end
Expand Down

0 comments on commit d99d569

Please sign in to comment.