diff --git a/base/array.jl b/base/array.jl index f13c6ee08358e..d573a1aa39d4d 100644 --- a/base/array.jl +++ b/base/array.jl @@ -687,8 +687,7 @@ function grow_to!(dest, itr, st) y = iterate(itr, st) while y !== nothing el, st = y - S = typeof(el) - if S === T || S <: T + if el isa T || typeof(el) === T push!(dest, el::T) else new = push_widen(dest, el) diff --git a/base/broadcast.jl b/base/broadcast.jl index 4ebc1cfcd9f22..194bbd489a515 100644 --- a/base/broadcast.jl +++ b/base/broadcast.jl @@ -926,13 +926,12 @@ function copyto_nonleaf!(dest, bc::Broadcasted, iter, state, count) y === nothing && break I, state = y @inbounds val = bc[I] - S = typeof(val) - if S <: T + if val isa T || typeof(val) === T @inbounds dest[I] = val else # This element type doesn't fit in dest. Allocate a new dest with wider eltype, # copy over old values, and continue - newdest = Base.similar(dest, promote_typejoin(T, S)) + newdest = Base.similar(dest, promote_typejoin(T, typeof(val))) for II in Iterators.take(iter, count) newdest[II] = dest[II] end