Skip to content

Commit 62362ad

Browse files
committed
Refactor to simplify
1 parent c35b7e4 commit 62362ad

File tree

2 files changed

+6
-18
lines changed

2 files changed

+6
-18
lines changed

src/copyable_task.jl

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -443,12 +443,10 @@ get_value(x) = x
443443
expression, otherwise `false`.
444444
"""
445445
function 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])

src/test_utils.jl

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,7 @@ function (case::Testcase)()
5959
end
6060

6161
for _ in iteration_results
62-
# TODO(mhauru) We seem to be causing more allocations than expected on
63-
# v1.12, needs investigating.
64-
@static if VERSION < v"1.12-"
65-
@test count_allocs(consume, t) == 0
66-
end
62+
@test count_allocs(consume, t) == 0
6763
end
6864
end
6965
end

0 commit comments

Comments
 (0)