From 09eb415320ce38a996a1a2a7b45e3091883565a3 Mon Sep 17 00:00:00 2001 From: Simeon Schaub Date: Sat, 21 Nov 2020 00:50:52 +0100 Subject: [PATCH] fix Meta.partially_inline! for ReturnNode --- base/meta.jl | 6 ++++++ test/meta.jl | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/base/meta.jl b/base/meta.jl index 4bbb1d1ecd3ba..a1356f16808e8 100644 --- a/base/meta.jl +++ b/base/meta.jl @@ -344,6 +344,12 @@ function _partially_inline!(@nospecialize(x), slot_replacements::Vector{Any}, x.edges .+= slot_offset return x end + if isa(x, Core.ReturnNode) + return Core.ReturnNode( + _partially_inline!(x.val, slot_replacements, type_signature, static_param_values, + slot_offset, statement_offset, boundscheck) + ) + end if isa(x, Expr) head = x.head if head === :static_parameter diff --git a/test/meta.jl b/test/meta.jl index 0ac16f16bc3c2..719ebf7a0048e 100644 --- a/test/meta.jl +++ b/test/meta.jl @@ -233,3 +233,8 @@ macro m() 2 end end @test _lower(TestExpandInWorldModule, :(@m), TestExpandInWorldModule.wa) == 1 + +f(::T) where {T} = T +ci = code_lowered(f, Tuple{Int})[1] +@test Meta.partially_inline!(ci.code, [], Tuple{typeof(f),Int}, Any[Int], 0, 0, :propagate) == + Any[Core.ReturnNode(QuoteNode(Int))]