diff --git a/base/array.jl b/base/array.jl index 8f642600f0347..b5a1ba31f0acf 100644 --- a/base/array.jl +++ b/base/array.jl @@ -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) @@ -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) diff --git a/base/broadcast.jl b/base/broadcast.jl index 0b9d1ac8297ee..7c32e6893268f 100644 --- a/base/broadcast.jl +++ b/base/broadcast.jl @@ -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, diff --git a/base/strings/basic.jl b/base/strings/basic.jl index 23e65ab4839a9..306ecc5cc214a 100644 --- a/base/strings/basic.jl +++ b/base/strings/basic.jl @@ -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)) """ @@ -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)) """ @@ -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 ## diff --git a/base/toml_parser.jl b/base/toml_parser.jl index c19572c2ebaed..7f4662bddc4dd 100644 --- a/base/toml_parser.jl +++ b/base/toml_parser.jl @@ -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)}