Skip to content
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

Stop using Core.Compiler.return_type #140

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Dictionary.jl
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,8 @@
tmp = iterate(iter)
if tmp === nothing
IT = Base.@default_eltype(iter)
I = IT == Union{} ? Union{} : Core.Compiler.return_type(first, Tuple{IT})
T = IT == Union{} ? Union{} : Core.Compiler.return_type(last, Tuple{IT})
I = Base.promote_op(first, IT)
T = Base.promote_op(last, IT)

Check warning on line 230 in src/Dictionary.jl

View check run for this annotation

Codecov / codecov/patch

src/Dictionary.jl#L229-L230

Added lines #L229 - L230 were not covered by tests
return Dictionary{I, T}()
end
(x, s) = tmp
Expand Down
5 changes: 2 additions & 3 deletions src/broadcast.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ _data(d::BroadcastedDictionary) = getfield(d, :data)
dicts = _dicts(data...)
sharetokens = _sharetokens(dicts...)
I = keytype(dicts[1])
Ts = Base.Broadcast.eltypes(data)
T = Core.Compiler.return_type(f, Ts)
T = Base.Broadcast.combine_eltypes(f, data)

return BroadcastedDictionary{I, T, typeof(f), typeof(data)}(f, data, sharetokens)
end
Expand Down Expand Up @@ -130,4 +129,4 @@ end
Base.Broadcast.materialize(d::BroadcastedDictionary) = copy(d)
Base.Broadcast.materialize!(out::AbstractDictionary, d::BroadcastedDictionary) = copyto!(out, d)

Base.Broadcast.materialize!(out::AbstractDictionary, bc::Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{0}, Nothing, typeof(identity)}) = fill!(out, bc.args[1][])
Base.Broadcast.materialize!(out::AbstractDictionary, bc::Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{0}, Nothing, typeof(identity)}) = fill!(out, bc.args[1][])
6 changes: 3 additions & 3 deletions src/map.jl
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,13 @@
end

function Base.map(f, d::AbstractDictionary)
out = similar(d, Core.Compiler.return_type(f, Tuple{eltype(d)}))
out = similar(d, Base.promote_op(f, eltype(d)))
@inbounds map!(f, out, d)
return out
end

function Base.map(f, d::AbstractDictionary, ds::AbstractDictionary...)
out = similar(d, Core.Compiler.return_type(f, Tuple{eltype(d), map(eltype, ds)...}))
out = similar(d, Base.promote_op(f, eltype(d), map(eltype, ds)...))
@inbounds map!(f, out, d, ds...)
return out
end
Expand Down Expand Up @@ -145,6 +145,6 @@

function Iterators.map(f, d::AbstractDictionary)
I = keytype(d)
T = Core.Compiler.return_type(f, Tuple{eltype(d)}) # Base normally wouldn't invoke inference for something like this...
T = Base.promote_op(f, eltype(d)) # Base normally wouldn't invoke inference for something like this...

Check warning on line 148 in src/map.jl

View check run for this annotation

Codecov / codecov/patch

src/map.jl#L148

Added line #L148 was not covered by tests
return MappedDictionary{I, T, typeof(f), Tuple{typeof(d)}}(f, (d,))
end
4 changes: 2 additions & 2 deletions test/map.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@testset "map" begin
function _mapview(f, d::AbstractDictionary)
I = keytype(d)
T = Core.Compiler.return_type(f, Tuple{eltype(d)})
T = Base.promote_op(f, eltype(d))

return MappedDictionary{I, T, typeof(f), Tuple{typeof(d)}}(f, (d,))
end
Expand All @@ -23,4 +23,4 @@

@test _mapview(iseven, d)::Dictionaries.MappedDictionary == dictionary([1=>false, 2=>false, 3=>true, 4=>true, 5=>false])
@test _mapview(isodd, d)::Dictionaries.MappedDictionary == dictionary([1=>true, 2=>true, 3=>false, 4=>false, 5=>true])
end
end
Loading