Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eliminate uninferrable typeof(x) === T conditions #45018

Merged
merged 1 commit into from
Apr 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions base/array.jl
Original file line number Diff line number Diff line change
Expand Up @@ -844,8 +844,8 @@ function collect_to!(dest::AbstractArray{T}, itr, offs, st) where T
y = iterate(itr, st)
y === nothing && break
el, st = y
if el isa T || typeof(el) === T
@inbounds dest[i] = el::T
if el isa T
@inbounds dest[i] = el
i += 1
else
new = setindex_widen_up_to(dest, el, i)
Expand Down Expand Up @@ -881,8 +881,8 @@ function grow_to!(dest, itr, st)
y = iterate(itr, st)
while y !== nothing
el, st = y
if el isa T || typeof(el) === T
push!(dest, el::T)
if el isa T
push!(dest, el)
else
new = push_widen(dest, el)
return grow_to!(new, itr, st)
Expand Down
2 changes: 1 addition & 1 deletion base/broadcast.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1053,7 +1053,7 @@ function copyto_nonleaf!(dest, bc::Broadcasted, iter, state, count)
y === nothing && break
I, state = y
@inbounds val = bc[I]
if val isa T || typeof(val) === T
if val isa T
@inbounds dest[I] = val
else
# This element type doesn't fit in dest. Allocate a new dest with wider eltype,
Expand Down
6 changes: 3 additions & 3 deletions base/strings/basic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ UInt8

See also [`ncodeunits`](@ref), [`checkbounds`](@ref).
"""
@propagate_inbounds codeunit(s::AbstractString, i::Integer) = typeof(i) === Int ?
@propagate_inbounds codeunit(s::AbstractString, i::Integer) = i isa Int ?
throw(MethodError(codeunit, (s, i))) : codeunit(s, Int(i))

"""
Expand Down Expand Up @@ -140,7 +140,7 @@ Stacktrace:
[...]
```
"""
@propagate_inbounds isvalid(s::AbstractString, i::Integer) = typeof(i) === Int ?
@propagate_inbounds isvalid(s::AbstractString, i::Integer) = i isa Int ?
throw(MethodError(isvalid, (s, i))) : isvalid(s, Int(i))

"""
Expand All @@ -154,7 +154,7 @@ protocol may assume that `i` is the start of a character in `s`.

See also [`getindex`](@ref), [`checkbounds`](@ref).
"""
@propagate_inbounds iterate(s::AbstractString, i::Integer) = typeof(i) === Int ?
@propagate_inbounds iterate(s::AbstractString, i::Integer) = i isa Int ?
throw(MethodError(iterate, (s, i))) : iterate(s, Int(i))

## basic generic definitions ##
Expand Down
2 changes: 1 addition & 1 deletion base/toml_parser.jl
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@ function push!!(v::Vector, el)
out[1] = el
return out
else
if typeof(T) === Union
if T isa Union
newT = Any
else
newT = Union{T, typeof(el)}
Expand Down