Skip to content

Commit

Permalink
leave out the tightening from this PR, with TODO note
Browse files Browse the repository at this point in the history
  • Loading branch information
nsajko committed Dec 24, 2024
1 parent d620954 commit 766286e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
13 changes: 5 additions & 8 deletions base/generator_eltype.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,12 @@ function eltype(::Type{Generator{A, typeof(identity)}}) where {A}
end

function eltype(::Type{Generator{A, Fix1{typeof(getindex), B}}}) where {A, B}
function h(::Type{Type{T}}) where {T}
T
end
function h(::Type{<:Type})
Any
end
if B <: Type
# a user may overload `getindex(user_type)` to return a non-`Vector` `AbstractVector`
AbstractVector{h(B)}
# TODO: theoretically we could be more precise here and return a subtype
# of `AbstractVector`. The problem is that several packages do dubious
# punning of `getindex`. See
# https://github.com/mcabbott/AxisKeys.jl/issues/163
Any
elseif (eltype(A) == keytype(B)) || ((eltype(A) <: Integer) && (keytype(B) <: Integer))
valtype(B)
else
Expand Down
4 changes: 0 additions & 4 deletions test/iterators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1016,10 +1016,6 @@ end
end

@testset "`eltype` for `Generator` involving `Fix` and `getindex`/`getfield` (issue #41519)" begin
@testset "special cases" begin
(f, i) = (Base.Fix1(getindex, Int), [3, 7])
@test AbstractVector{Int} >: @inferred eltype(Iterators.map(f, i))
end
@testset "correct `eltype`" begin
for (f, i) (
(Base.Fix1(getindex, Int), [3, 7]),
Expand Down

0 comments on commit 766286e

Please sign in to comment.