Skip to content

Commit 6ee784d

Browse files
authored
Improve type inference of Artifacts.jl (JuliaLang#56118)
This also has some changes that move platform selection to compile time together with JuliaPackaging/JLLWrappers.jl@45cc049, move the platform selection to compile time. (this helps juliac a ton)
1 parent 54299d9 commit 6ee784d

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

stdlib/Artifacts/src/Artifacts.jl

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ function artifact_hash(name::String, artifacts_toml::String;
443443
return nothing
444444
end
445445

446-
return SHA1(meta["git-tree-sha1"])
446+
return SHA1(meta["git-tree-sha1"]::String)
447447
end
448448

449449
function select_downloadable_artifacts(artifact_dict::Dict, artifacts_toml::String;
@@ -642,10 +642,9 @@ function artifact_slash_lookup(name::String, artifact_dict::Dict,
642642
if meta === nothing
643643
error("Cannot locate artifact '$(name)' for $(triplet(platform)) in '$(artifacts_toml)'")
644644
end
645-
hash = SHA1(meta["git-tree-sha1"])
645+
hash = SHA1(meta["git-tree-sha1"]::String)
646646
return artifact_name, artifact_path_tail, hash
647647
end
648-
649648
"""
650649
macro artifact_str(name)
651650
@@ -707,17 +706,16 @@ macro artifact_str(name, platform=nothing)
707706

708707
# If `name` is a constant, (and we're using the default `Platform`) we can actually load
709708
# and parse the `Artifacts.toml` file now, saving the work from runtime.
710-
if isa(name, AbstractString) && platform === nothing
711-
# To support slash-indexing, we need to split the artifact name from the path tail:
709+
if platform === nothing
712710
platform = HostPlatform()
711+
end
712+
if isa(name, AbstractString) && isa(platform, AbstractPlatform)
713+
# To support slash-indexing, we need to split the artifact name from the path tail:
713714
artifact_name, artifact_path_tail, hash = artifact_slash_lookup(name, artifact_dict, artifacts_toml, platform)
714715
return quote
715716
Base.invokelatest(_artifact_str, $(__module__), $(artifacts_toml), $(artifact_name), $(artifact_path_tail), $(artifact_dict), $(hash), $(platform), Val($(LazyArtifacts)))::String
716717
end
717718
else
718-
if platform === nothing
719-
platform = :($(HostPlatform)())
720-
end
721719
return quote
722720
local platform = $(esc(platform))
723721
local artifact_name, artifact_path_tail, hash = artifact_slash_lookup($(esc(name)), $(artifact_dict), $(artifacts_toml), platform)

0 commit comments

Comments
 (0)