This seems to be a limitation of the @code_… macros. If you look at the corresponding function e.g.:
help?> code_lowered
search: code_lowered @code_lowered
code_lowered(f, types; generated=true, debuginfo=:default)
...
you see, that it is working only on the types, e.g.:
ulia> code_lowered( ^, (Int,Int) )
1-element Vector{Core.CodeInfo}:
CodeInfo(
1 ─ %1 = Base.power_by_squaring(x, p)
└── return %1
)
therefor you get the the wrong implementation. You can overcome this by:
julia> function show_power()
res=^(2,-5)
end
show_power (generic function with 1 method)
julia> @code_lowered show_power()
CodeInfo(
1 ─ %1 = Core.apply_type(Base.Val, -5)
│ %2 = (%1)()
│ %3 = Base.literal_pow(Main.:^, 2, %2)
│ res = %3
└── return %3
)
You see now that Base.literal_pow is actually called.
(expanded on @sgaure answer)