Skip to content

Commit

Permalink
Fix implicit convert(String, ...) in several places (#56174)
Browse files Browse the repository at this point in the history
This removes several `convert(String, ...)` from this code, which really
shouldn't be something we invalidate on in the first place (see
#56173) but this is still an
improvement in code quality so let's take it.
  • Loading branch information
topolarity authored Oct 16, 2024
1 parent 924dc17 commit a7521ea
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
21 changes: 13 additions & 8 deletions base/precompilation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ function ExplicitEnv(envpath::String=Base.active_project())

# Collect all direct dependencies of the project
for key in ["deps", "weakdeps", "extras"]
for (name, _uuid::String) in get(Dict{String, Any}, project_d, key)::Dict{String, Any}
for (name, _uuid) in get(Dict{String, Any}, project_d, key)::Dict{String, Any}
v = key == "deps" ? project_deps :
key == "weakdeps" ? project_weakdeps :
key == "extras" ? project_extras :
error()
uuid = UUID(_uuid)
uuid = UUID(_uuid::String)
v[name] = uuid
names[UUID(uuid)] = name
project_uuid_to_name[name] = UUID(uuid)
Expand All @@ -75,9 +75,11 @@ function ExplicitEnv(envpath::String=Base.active_project())

project_extensions = Dict{String, Vector{UUID}}()
# Collect all extensions of the project
for (name, triggers::Union{String, Vector{String}}) in get(Dict{String, Any}, project_d, "extensions")::Dict{String, Any}
for (name, triggers) in get(Dict{String, Any}, project_d, "extensions")::Dict{String, Any}
if triggers isa String
triggers = [triggers]
else
triggers = triggers::Vector{String}
end
uuids = UUID[]
for trigger in triggers
Expand Down Expand Up @@ -107,8 +109,9 @@ function ExplicitEnv(envpath::String=Base.active_project())
sizehint!(name_to_uuid, length(manifest_d))
sizehint!(lookup_strategy, length(manifest_d))

for (name, pkg_infos::Vector{Any}) in get_deps(manifest_d)
for pkg_info::Dict{String, Any} in pkg_infos
for (name, pkg_infos) in get_deps(manifest_d)
for pkg_info in pkg_infos::Vector{Any}
pkg_info = pkg_info::Dict{String, Any}
m_uuid = UUID(pkg_info["uuid"]::String)

# If we have multiple packages with the same name we will overwrite things here
Expand All @@ -129,8 +132,8 @@ function ExplicitEnv(envpath::String=Base.active_project())
# Expanded format:
else
uuids = UUID[]
for (name_dep, _dep_uuid::String) in deps_pkg
dep_uuid = UUID(_dep_uuid)
for (name_dep, _dep_uuid) in deps_pkg
dep_uuid = UUID(_dep_uuid::String)
push!(uuids, dep_uuid)
names[dep_uuid] = name_dep
end
Expand All @@ -140,9 +143,11 @@ function ExplicitEnv(envpath::String=Base.active_project())

# Extensions
deps_pkg = get(Dict{String, Any}, pkg_info, "extensions")::Dict{String, Any}
for (ext, triggers::Union{String, Vector{String}}) in deps_pkg
for (ext, triggers) in deps_pkg
if triggers isa String
triggers = [triggers]
else
triggers = triggers::Vector{String}
end
deps_pkg[ext] = triggers
end
Expand Down
2 changes: 1 addition & 1 deletion base/regex.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ mutable struct Regex <: AbstractPattern

function Regex(pattern::AbstractString, compile_options::Integer,
match_options::Integer)
pattern = String(pattern)
pattern = String(pattern)::String
compile_options = UInt32(compile_options)
match_options = UInt32(match_options)
if (compile_options & ~PCRE.COMPILE_MASK) != 0
Expand Down
2 changes: 1 addition & 1 deletion stdlib/REPL/src/LineEdit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ region_active(s::PromptState) = s.region_active
region_active(s::ModeState) = :off


input_string(s::PromptState) = String(take!(copy(s.input_buffer)))
input_string(s::PromptState) = String(take!(copy(s.input_buffer)))::String

input_string_newlines(s::PromptState) = count(c->(c == '\n'), input_string(s))
function input_string_newlines_aftercursor(s::PromptState)
Expand Down

0 comments on commit a7521ea

Please sign in to comment.