Skip to content
This repository has been archived by the owner on May 29, 2024. It is now read-only.

Commit

Permalink
tweak(interaction/externals): try newest methods
Browse files Browse the repository at this point in the history
The return order of `methods` is by no means guaranteed, and so at the
very least we should try newer methods first (by sorting according to
the method world).
  • Loading branch information
tecosaur committed May 23, 2024
1 parent 36509b9 commit 21ec641
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/interaction/externals.jl
Original file line number Diff line number Diff line change
Expand Up @@ -429,20 +429,22 @@ const genericstoreput = first(methods(putstorage, Tuple{DataStorage{Any}, Any}))

supportedtypes(L::Type{<:DataLoader}, T::Type=Any)::Vector{QualifiedType} =
map(fn -> extracttypes(Base.unwrap_unionall(fn.sig).types[4]),
methods(load, Tuple{L, T, Any})) |>
sort(methods(load, Tuple{L, T, Any}), by=m->m.primary_world)) |>
Iterators.flatten .|> QualifiedType |> unique |> reverse

supportedtypes(W::Type{<:DataWriter}, T::Type=Any)::Vector{QualifiedType} =
map(fn -> QualifiedType(Base.unwrap_unionall(fn.sig).types[4]),
methods(save, Tuple{W, T, Any})) |> unique |> reverse
sort(methods(save, Tuple{W, T, Any}), by=m->m.primary_world)) |>
unique |> reverse

supportedtypes(S::Type{<:DataStorage})::Vector{QualifiedType} =
map(fn -> extracttypes(Base.unwrap_unionall(fn.sig).types[3]),
let ms = filter(m -> m != genericstore, methods(storage, Tuple{S, Any}))
let ms = filter(m -> m != genericstore,
sort(methods(storage, Tuple{S, Any}), by=m->m.primary_world))
if isempty(ms)
vcat(filter(m -> m != genericstoreget,
methods(getstorage, Tuple{S, Any})),
sort(methods(getstorage, Tuple{S, Any}), by=m->m.primary_world)),
filter(m -> m != genericstoreput,
methods(putstorage, Tuple{S, Any})))
sort(methods(putstorage, Tuple{S, Any}), by=m->m.primary_world)))
else ms end
end) |> Iterators.flatten .|> QualifiedType |> unique |> reverse

0 comments on commit 21ec641

Please sign in to comment.