From eb791177629d8dc6a8de7a64e3fa9abca67d772f Mon Sep 17 00:00:00 2001 From: Shuhei Kadowaki Date: Wed, 30 Nov 2022 17:36:54 +0900 Subject: [PATCH] follow up #47739 --- base/reflection.jl | 5 +++-- test/staged.jl | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/base/reflection.jl b/base/reflection.jl index 7c251dfe6a4f2..220a2cae2d19e 100644 --- a/base/reflection.jl +++ b/base/reflection.jl @@ -1165,7 +1165,8 @@ function may_invoke_generator(method::Method, @nospecialize(atype), sparams::Sim end end end - non_va_args = method.isva ? method.nargs - 1 : method.nargs + nargs = Int(method.nargs) + non_va_args = method.isva ? nargs - 1 : nargs for i = 1:non_va_args if !isdispatchelem(at.parameters[i]) if (ast_slotflag(code, 1 + i + nsparams) & SLOT_USED) != 0 @@ -1176,7 +1177,7 @@ function may_invoke_generator(method::Method, @nospecialize(atype), sparams::Sim if method.isva # If the va argument is used, we need to ensure that all arguments that # contribute to the va tuple are dispatchelemes - if (ast_slotflag(code, 1 + method.nargs + nsparams) & SLOT_USED) != 0 + if (ast_slotflag(code, 1 + nargs + nsparams) & SLOT_USED) != 0 for i = (non_va_args+1):length(at.parameters) if !isdispatchelem(at.parameters[i]) return false diff --git a/test/staged.jl b/test/staged.jl index 516baea93ec04..8c260c0048acd 100644 --- a/test/staged.jl +++ b/test/staged.jl @@ -313,10 +313,10 @@ end end g_vararg_generated() = f_vararg_generated((;), (;), Base.inferencebarrier((;))) let tup = g_vararg_generated() - @test !any(==(Any), tup) + @test all(==(typeof((;))), tup) # This is just to make sure that the test is actually testing what we want - # the test only works if there's an unused that matches the position of the # inferencebarrier argument above (N.B. the generator function itself # shifts everything over by 1) - @test code_lowered(first(methods(f_vararg_generated)).generator.gen)[1].slotflags[5] == UInt8(0x00) + @test only(code_lowered(only(methods(f_vararg_generated)).generator.gen)).slotflags[5] == UInt8(0x00) end