Skip to content

Commit a7521ea

Browse files
authored
Fix implicit convert(String, ...) in several places (JuliaLang#56174)
This removes several `convert(String, ...)` from this code, which really shouldn't be something we invalidate on in the first place (see JuliaLang#56173) but this is still an improvement in code quality so let's take it.
1 parent 924dc17 commit a7521ea

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
@@ -43,12 +43,12 @@ function ExplicitEnv(envpath::String=Base.active_project())
4343

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

7676
project_extensions = Dict{String, Vector{UUID}}()
7777
# Collect all extensions of the project
78-
for (name, triggers::Union{String, Vector{String}}) in get(Dict{String, Any}, project_d, "extensions")::Dict{String, Any}
78+
for (name, triggers) in get(Dict{String, Any}, project_d, "extensions")::Dict{String, Any}
7979
if triggers isa String
8080
triggers = [triggers]
81+
else
82+
triggers = triggers::Vector{String}
8183
end
8284
uuids = UUID[]
8385
for trigger in triggers
@@ -107,8 +109,9 @@ function ExplicitEnv(envpath::String=Base.active_project())
107109
sizehint!(name_to_uuid, length(manifest_d))
108110
sizehint!(lookup_strategy, length(manifest_d))
109111

110-
for (name, pkg_infos::Vector{Any}) in get_deps(manifest_d)
111-
for pkg_info::Dict{String, Any} in pkg_infos
112+
for (name, pkg_infos) in get_deps(manifest_d)
113+
for pkg_info in pkg_infos::Vector{Any}
114+
pkg_info = pkg_info::Dict{String, Any}
112115
m_uuid = UUID(pkg_info["uuid"]::String)
113116

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

141144
# Extensions
142145
deps_pkg = get(Dict{String, Any}, pkg_info, "extensions")::Dict{String, Any}
143-
for (ext, triggers::Union{String, Vector{String}}) in deps_pkg
146+
for (ext, triggers) in deps_pkg
144147
if triggers isa String
145148
triggers = [triggers]
149+
else
150+
triggers = triggers::Vector{String}
146151
end
147152
deps_pkg[ext] = triggers
148153
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)