Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make reinterpret specialize fully. #50670

Merged
merged 2 commits into from
Jul 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions base/essentials.jl
Original file line number Diff line number Diff line change
Expand Up @@ -571,8 +571,8 @@ julia> reinterpret(Tuple{UInt16, UInt8}, (0x01, 0x0203))
otherwise be prevented by the type's constructors and methods. Unexpected behavior
may result without additional validation.
"""
function reinterpret(Out::Type, x::In) where {In}
if isprimitivetype(Out) && isprimitivetype(In)
function reinterpret(::Type{Out}, x) where {Out}
if isprimitivetype(Out) && isprimitivetype(typeof(x))
return bitcast(Out, x)
end
# only available when Base is fully loaded.
Expand Down
4 changes: 4 additions & 0 deletions test/compiler/inline.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2061,3 +2061,7 @@ let src = code_typed1((Union{DataType,UnionAll},); interp=NoCompileSigInvokes())
(x.args[1]::MethodInstance).specTypes == Tuple{typeof(no_compile_sig_invokes),UnionAll}
end == 1
end

# https://github.com/JuliaLang/julia/issues/50612
f50612(x) = UInt32(x)
@test all(!isinvoke(:UInt32),get_code(f50612,Tuple{Char}))