@@ -443,12 +443,10 @@ get_value(x) = x
443443expression, otherwise `false`.
444444"""
445445function is_produce_stmt (x):: Bool
446- if Meta. isexpr (x, :invoke ) && length (x. args) == 3 && x. args[1 ] isa Core. MethodInstance
447- # This branch is hit on Julia 1.11 and earlier.
448- return x. args[1 ]. specTypes <: Tuple{typeof(produce),Any}
449- elseif Meta. isexpr (x, :invoke ) && length (x. args) == 3 && x. args[1 ] isa Core. CodeInstance
450- # This branch is hit on Julia 1.12.
451- return x. args[1 ]. def. specTypes <: Tuple{typeof(produce),Any}
446+ if Meta. isexpr (x, :invoke ) &&
447+ length (x. args) == 3 &&
448+ x. args[1 ] isa Union{Core. MethodInstance,Core. CodeInstance}
449+ return get_mi (x. args[1 ]). specTypes <: Tuple{typeof(produce),Any}
452450 elseif Meta. isexpr (x, :call ) && length (x. args) == 2
453451 return get_value (x. args[1 ]) === produce
454452 else
@@ -471,13 +469,7 @@ function stmt_might_produce(x, ret_type::Type)::Bool
471469
472470 # Statement will terminate in the usual fashion, so _do_ bother recusing.
473471 is_produce_stmt (x) && return true
474- @static if VERSION >= v " 1.12-"
475- # On Julia 1.12 x.args has CodeInstances rather than MethodInstances. We use .def
476- # to get the MethodInstances.
477- Meta. isexpr (x, :invoke ) && return might_produce (x. args[1 ]. def. specTypes)
478- else
479- Meta. isexpr (x, :invoke ) && return might_produce (x. args[1 ]. specTypes)
480- end
472+ Meta. isexpr (x, :invoke ) && return might_produce (get_mi (x. args[1 ]). specTypes)
481473 if Meta. isexpr (x, :call )
482474 # This is a hack -- it's perfectly possible for `DataType` calls to produce in general.
483475 f = get_function (x. args[1 ])
0 commit comments