Skip to content

Commit b53bbe5

Browse files
topolarityKristofferC
authored andcommitted
Fix implicit convert(String, ...) in several places (#56174)
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. (cherry picked from commit a7521ea)
1 parent 276e66c commit b53bbe5

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed

base/precompilation.jl

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@ function ExplicitEnv(envpath::String=Base.active_project())
4242

4343
# Collect all direct dependencies of the project
4444
for key in ["deps", "weakdeps", "extras"]
45-
for (name, _uuid::String) in get(Dict{String, Any}, project_d, key)::Dict{String, Any}
45+
for (name, _uuid) in get(Dict{String, Any}, project_d, key)::Dict{String, Any}
4646
v = key == "deps" ? project_deps :
4747
key == "weakdeps" ? project_weakdeps :
4848
key == "extras" ? project_extras :
4949
error()
50-
uuid = UUID(_uuid)
50+
uuid = UUID(_uuid::String)
5151
v[name] = uuid
5252
names[UUID(uuid)] = name
5353
project_uuid_to_name[name] = UUID(uuid)
@@ -61,9 +61,11 @@ function ExplicitEnv(envpath::String=Base.active_project())
6161

6262
project_extensions = Dict{String, Vector{UUID}}()
6363
# Collect all extensions of the project
64-
for (name, triggers::Union{String, Vector{String}}) in get(Dict{String, Any}, project_d, "extensions")::Dict{String, Any}
64+
for (name, triggers) in get(Dict{String, Any}, project_d, "extensions")::Dict{String, Any}
6565
if triggers isa String
6666
triggers = [triggers]
67+
else
68+
triggers = triggers::Vector{String}
6769
end
6870
uuids = UUID[]
6971
for trigger in triggers
@@ -105,8 +107,9 @@ function ExplicitEnv(envpath::String=Base.active_project())
105107
sizehint!(name_to_uuid, length(manifest_d))
106108
sizehint!(lookup_strategy, length(manifest_d))
107109

108-
for (name, pkg_infos::Vector{Any}) in get_deps(manifest_d)
109-
for pkg_info::Dict{String, Any} in pkg_infos
110+
for (name, pkg_infos) in get_deps(manifest_d)
111+
for pkg_info in pkg_infos::Vector{Any}
112+
pkg_info = pkg_info::Dict{String, Any}
110113
m_uuid = UUID(pkg_info["uuid"]::String)
111114

112115
# If we have multiple packages with the same name we will overwrite things here
@@ -127,8 +130,8 @@ function ExplicitEnv(envpath::String=Base.active_project())
127130
# Expanded format:
128131
else
129132
uuids = UUID[]
130-
for (name_dep, _dep_uuid::String) in deps_pkg
131-
dep_uuid = UUID(_dep_uuid)
133+
for (name_dep, _dep_uuid) in deps_pkg
134+
dep_uuid = UUID(_dep_uuid::String)
132135
push!(uuids, dep_uuid)
133136
names[dep_uuid] = name_dep
134137
end
@@ -138,9 +141,11 @@ function ExplicitEnv(envpath::String=Base.active_project())
138141

139142
# Extensions
140143
deps_pkg = get(Dict{String, Any}, pkg_info, "extensions")::Dict{String, Any}
141-
for (ext, triggers::Union{String, Vector{String}}) in deps_pkg
144+
for (ext, triggers) in deps_pkg
142145
if triggers isa String
143146
triggers = [triggers]
147+
else
148+
triggers = triggers::Vector{String}
144149
end
145150
deps_pkg[ext] = triggers
146151
end

base/regex.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ mutable struct Regex <: AbstractPattern
2828

2929
function Regex(pattern::AbstractString, compile_options::Integer,
3030
match_options::Integer)
31-
pattern = String(pattern)
31+
pattern = String(pattern)::String
3232
compile_options = UInt32(compile_options)
3333
match_options = UInt32(match_options)
3434
if (compile_options & ~PCRE.COMPILE_MASK) != 0

stdlib/REPL/src/LineEdit.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ region_active(s::PromptState) = s.region_active
166166
region_active(s::ModeState) = :off
167167

168168

169-
input_string(s::PromptState) = String(take!(copy(s.input_buffer)))
169+
input_string(s::PromptState) = String(take!(copy(s.input_buffer)))::String
170170

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

0 commit comments

Comments
 (0)