Skip to content

Commit 7beb67e

Browse files
authored
Enhance inference for methods extended in BinaryPlatforms (#3020)
* Use Union in BinaryPlatform calls to enhance inference With MAX_METHODS=3, the former implementation got in the way of successful abstract inference. This implementation fares better. Co-authored-by: Elliot Saba <[email protected]> * Inference improvement in TOML-Dict call
1 parent c81031d commit 7beb67e

File tree

2 files changed

+21
-19
lines changed

2 files changed

+21
-19
lines changed

src/BinaryPlatforms_compat.jl

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -60,33 +60,35 @@ for T in (:Linux, :Windows, :MacOS, :FreeBSD)
6060
end
6161
end
6262
end
63+
end
6364

64-
# First, methods we need to coerce to Symbol for backwards-compatibility
65-
for f in (:arch, :libc, :call_abi, :cxxstring_abi)
66-
@eval begin
67-
function $(f)(p::$(T))
68-
str = $(f)(p.p)
69-
if str === nothing
70-
return nothing
71-
end
72-
return Symbol(str)
73-
end
74-
end
75-
end
65+
const PlatformUnion = Union{Linux,MacOS,Windows,FreeBSD}
7666

77-
# Next, things we don't need to coerce
78-
for f in (:libgfortran_version, :libstdcxx_version, :platform_name, :wordsize, :platform_dlext, :tags, :triplet)
79-
@eval begin
80-
$(f)(p::$(T)) = $(f)(p.p)
67+
# First, methods we need to coerce to Symbol for backwards-compatibility
68+
for f in (:arch, :libc, :call_abi, :cxxstring_abi)
69+
@eval begin
70+
function $(f)(p::PlatformUnion)
71+
str = $(f)(p.p)
72+
if str === nothing
73+
return nothing
74+
end
75+
return Symbol(str)
8176
end
8277
end
78+
end
8379

84-
# Finally, add equality testing between these wrapper types and other AbstractPlatforms
80+
# Next, things we don't need to coerce
81+
for f in (:libgfortran_version, :libstdcxx_version, :platform_name, :wordsize, :platform_dlext, :tags, :triplet)
8582
@eval begin
86-
Base.:(==)(a::$(T), b::AbstractPlatform) = b == a.p
83+
$(f)(p::PlatformUnion) = $(f)(p.p)
8784
end
8885
end
8986

87+
# Finally, add equality testing between these wrapper types and other AbstractPlatforms
88+
@eval begin
89+
Base.:(==)(a::PlatformUnion, b::AbstractPlatform) = b == a.p
90+
end
91+
9092
# Add one-off functions
9193
MacOS(; kwargs...) = MacOS(:x86_64; kwargs...)
9294
FreeBSD(; kwargs...) = FreeBSD(:x86_64; kwargs...)

src/Registry/registry_instance.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ function verify_compressed_registry_toml(path::String)
330330
return false
331331
end
332332
end
333-
compressed_file = joinpath(dirname(path), d["path"])
333+
compressed_file = joinpath(dirname(path), convert(String, d["path"])::String)
334334
if !isfile(compressed_file)
335335
@warn "Expected the compressed registry for $(repr(path)) to exist at $(repr(compressed_file))"
336336
return false

0 commit comments

Comments
 (0)