Skip to content

Commit 351b41a

Browse files
authored
inference: Don't try to infer optimized opaque_closure (JuliaLang#56557)
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.
1 parent ecf9677 commit 351b41a

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/abstractinterpretation.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2633,6 +2633,14 @@ function abstract_call_opaque_closure(interp::AbstractInterpreter,
26332633
ocsig = rewrap_unionall(Tuple{Tuple, ocargsig′.parameters...}, ocargsig)
26342634
hasintersect(sig, ocsig) || return Future(CallMeta(Union{}, Union{MethodError,TypeError}, EFFECTS_THROWS, NoCallInfo()))
26352635
ocmethod = closure.source::Method
2636+
if !isdefined(ocmethod, :source)
2637+
# This opaque closure was created from optimized source. We cannot infer it further.
2638+
ocrt = rewrap_unionall((unwrap_unionall(tt)::DataType).parameters[2], tt)
2639+
if isa(ocrt, DataType)
2640+
return Future(CallMeta(ocrt, Any, Effects(), NoCallInfo()))
2641+
end
2642+
return Future(CallMeta(Any, Any, Effects(), NoCallInfo()))
2643+
end
26362644
match = MethodMatch(sig, Core.svec(), ocmethod, sig <: ocsig)
26372645
mresult = abstract_call_method(interp, ocmethod, sig, Core.svec(), false, si, sv)
26382646
ocsig_box = Core.Box(ocsig)

src/stmtinfo.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ allow the optimizer to rewrite the return type parameter of the `OpaqueClosure`
352352
struct OpaqueClosureCreateInfo <: CallInfo
353353
unspec::CallMeta
354354
function OpaqueClosureCreateInfo(unspec::CallMeta)
355-
@assert isa(unspec.info, OpaqueClosureCallInfo)
355+
@assert isa(unspec.info, Union{OpaqueClosureCallInfo, NoCallInfo})
356356
return new(unspec)
357357
end
358358
end

0 commit comments

Comments
 (0)