-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Audit iterator traits to make sure they're always called on types #25733
Conversation
base/iterators.jl
Outdated
@@ -748,7 +748,7 @@ function IteratorEltype(::Type{ProductIterator{T}}) where {T<:Tuple} | |||
IteratorEltype(I) == EltypeUnknown() ? EltypeUnknown() : IteratorEltype(P) | |||
end | |||
|
|||
eltype(P::ProductIterator) = _prod_eltype(P.iterators) | |||
eltype(::Type{<:ProductIterator{I}}) where {I} = _prod_eltype((I.parameters...,)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally these should be rewritten to use tuple_type_head
.
base/reinterpretarray.jl
Outdated
@@ -35,7 +35,7 @@ end | |||
|
|||
parent(a::ReinterpretArray) = a.parent | |||
|
|||
eltype(a::ReinterpretArray{T}) where {T} = T | |||
eltype(a::Type{<:ReinterpretArray{T}}) where {T} = T |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unnecessary; should be inherited from AbstractArray.
stdlib/Test/src/Test.jl
Outdated
@@ -1456,6 +1456,7 @@ for (G, A) in ((GenericSet, AbstractSet), | |||
Base.$f(s::$G) = $f(s.s) | |||
end | |||
end | |||
Base.eltype(::Type{<:G}) = eltype(fieldtype(G, :s)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also covered by AbstractSet I think.
The iterator wrappers assume that eltype is called on the type of the wrapped iterator, not the value itself, so all objects that implement these traits need to do so. Audit all of them in base and make sure that's the case.
This forgot to update the docstring
|
The iterator wrappers assume that eltype is called on the type of
the wrapped iterator, not the value itself, so all objects that
implement these traits need to do so. Audit all of them in base
and make sure that's the case.