diff --git a/Compiler/src/abstractinterpretation.jl b/Compiler/src/abstractinterpretation.jl index 67e7ecfbce66a..faaba0c2dc44f 100644 --- a/Compiler/src/abstractinterpretation.jl +++ b/Compiler/src/abstractinterpretation.jl @@ -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) diff --git a/Compiler/src/stmtinfo.jl b/Compiler/src/stmtinfo.jl index 4cbd2ab39fd46..83d0b66e4d564 100644 --- a/Compiler/src/stmtinfo.jl +++ b/Compiler/src/stmtinfo.jl @@ -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