JuliaInterop / Clang.jl

C binding generator and Julia interface to libclang
https://juliainterop.github.io/Clang.jl/
MIT License
222 stars 68 forks source link

Use the concrete RefValue type to avoid method ambiguities #474

Closed JamesWrigley closed 7 months ago

JamesWrigley commented 7 months ago

On 1.11 there's a new unsafe_convert(::Type{Ptr{T}}, a::GenericMemoryRef) method which causes ambiguity errors with just Ref in the unsafe_convert() methods we define, so now we use the concrete RefValue.

This fixes ambiguity warnings from Aqua.jl, e.g:

2 ambiguities found
Ambiguity #1
unsafe_convert(::Type{Ptr{LibSSH.lib.__JL_sftp_packet_struct}}, x::Ref{LibSSH.lib.sftp_packet_struct}) @ LibSSH.lib ~/work/LibSSH.jl/LibSSH.jl/src/bindings.jl:2685
unsafe_convert(::Type{Ptr{T}}, a::GenericMemoryRef) where T @ Base pointer.jl:90

Possible fix, define
  unsafe_convert(::Type{Ptr{LibSSH.lib.__JL_sftp_packet_struct}}, ::GenericMemoryRef{isatomic, LibSSH.lib.sftp_packet_struct} where isatomic)

I also renamed the partial_nodes field to partially_emitted_nodes for clarity in ab0b3d5.

Gnimuc commented 7 months ago

LGTM