Skip to content
This repository has been archived by the owner on Sep 1, 2020. It is now read-only.

Commit

Permalink
Fix _chain_is for 0.6
Browse files Browse the repository at this point in the history
  • Loading branch information
iamed2 committed Apr 5, 2017
1 parent 1864ed0 commit 8fc901e
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions src/Iterators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -124,20 +124,7 @@ immutable Chain{T<:Tuple}
xss::T
end

if VERSION >= v"0.5.0-dev+3305"
iteratorsize{T}(::Type{Chain{T}}) = _chain_is(T)

@generated function _chain_is{T}(t::Type{T})
for itype in T.types
if iteratorsize(itype) == IsInfinite()
return :(IsInfinite())
elseif iteratorsize(itype) == SizeUnknown()
return :(SizeUnknown())
end
end
return :(HasLength())
end
end
# iteratorsize method defined at bottom because of how @generated functions work in 0.6 now

chain(xss...) = Chain(xss)

Expand Down Expand Up @@ -861,4 +848,21 @@ macro chain(ex)
Expr(:let, Expr(:block, cycleex...), states...)
end

if VERSION >= v"0.5.0-dev+3305"
iteratorsize{T}(::Type{Chain{T}}) = _chain_is(T)

# on 0.6, must be defined after the other iteratorsize methods are defined
# generated functions probably should not be used going forward
@generated function _chain_is{T}(t::Type{T})
for itype in T.types
if iteratorsize(itype) == IsInfinite()
return :(IsInfinite())
elseif iteratorsize(itype) == SizeUnknown()
return :(SizeUnknown())
end
end
return :(HasLength())
end
end

end # module Iterators

0 comments on commit 8fc901e

Please sign in to comment.