From a6760c9db2e9b5fbc05161fbc42147f25be7792b Mon Sep 17 00:00:00 2001 From: Oscar Smith Date: Fri, 23 Feb 2024 13:35:25 -0500 Subject: [PATCH 1/8] remove use of `Core.Compiler.return_type` --- src/Dictionary.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Dictionary.jl b/src/Dictionary.jl index d394966..5d6991b 100644 --- a/src/Dictionary.jl +++ b/src/Dictionary.jl @@ -226,8 +226,8 @@ function _dictionary(key, value, ::Type{Dictionary}, iter) 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) return Dictionary{I, T}() end (x, s) = tmp From 62db42638f4847ddfd6ba7b5dc9c539ded2ff192 Mon Sep 17 00:00:00 2001 From: Oscar Smith Date: Fri, 23 Feb 2024 14:00:53 -0500 Subject: [PATCH 2/8] move to promote_op --- test/map.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/map.jl b/test/map.jl index a9aef5b..d31a3bb 100644 --- a/test/map.jl +++ b/test/map.jl @@ -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, Tuple{eltype(d)}) return MappedDictionary{I, T, typeof(f), Tuple{typeof(d)}}(f, (d,)) end @@ -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 \ No newline at end of file +end From b0e18233189167c49260188e5fb877d0554779bc Mon Sep 17 00:00:00 2001 From: Oscar Smith Date: Fri, 23 Feb 2024 14:01:39 -0500 Subject: [PATCH 3/8] Update broadcast.jl --- src/broadcast.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/broadcast.jl b/src/broadcast.jl index 3cbdded..c043783 100644 --- a/src/broadcast.jl +++ b/src/broadcast.jl @@ -19,7 +19,7 @@ _data(d::BroadcastedDictionary) = getfield(d, :data) sharetokens = _sharetokens(dicts...) I = keytype(dicts[1]) Ts = Base.Broadcast.eltypes(data) - T = Core.Compiler.return_type(f, Ts) + T = Base.promote_op(f, Ts) return BroadcastedDictionary{I, T, typeof(f), typeof(data)}(f, data, sharetokens) end @@ -130,4 +130,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][]) \ No newline at end of file +Base.Broadcast.materialize!(out::AbstractDictionary, bc::Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{0}, Nothing, typeof(identity)}) = fill!(out, bc.args[1][]) From d3d6d671291d92aafa12a7ac2ed464c4b5c90d47 Mon Sep 17 00:00:00 2001 From: Oscar Smith Date: Fri, 23 Feb 2024 14:06:04 -0500 Subject: [PATCH 4/8] Update map.jl --- src/map.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/map.jl b/src/map.jl index 233dae2..f81a6ca 100644 --- a/src/map.jl +++ b/src/map.jl @@ -88,13 +88,13 @@ function Base.map!(f, out::AbstractDictionary) 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 @@ -145,6 +145,6 @@ empty_type(::Type{<:MappedDictionary{<:Any, <:Any, <:Any, <:Tuple{D, Vararg{Abst 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... return MappedDictionary{I, T, typeof(f), Tuple{typeof(d)}}(f, (d,)) end From 5f016331d0e0052b223c9a0d6a40ee0af0160957 Mon Sep 17 00:00:00 2001 From: Oscar Smith Date: Fri, 23 Feb 2024 14:08:05 -0500 Subject: [PATCH 5/8] Update map.jl --- test/map.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/map.jl b/test/map.jl index d31a3bb..ee4531d 100644 --- a/test/map.jl +++ b/test/map.jl @@ -1,7 +1,7 @@ @testset "map" begin function _mapview(f, d::AbstractDictionary) I = keytype(d) - T = Base.promote_op(f, Tuple{eltype(d)}) + T = Base.promote_op(f, eltype(d)) return MappedDictionary{I, T, typeof(f), Tuple{typeof(d)}}(f, (d,)) end From d4cd9051c49bbc4923a9702b3a083a939cd8cba6 Mon Sep 17 00:00:00 2001 From: Oscar Smith Date: Fri, 23 Feb 2024 14:10:18 -0500 Subject: [PATCH 6/8] Update broadcast.jl --- src/broadcast.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/broadcast.jl b/src/broadcast.jl index c043783..ad74273 100644 --- a/src/broadcast.jl +++ b/src/broadcast.jl @@ -19,7 +19,7 @@ _data(d::BroadcastedDictionary) = getfield(d, :data) sharetokens = _sharetokens(dicts...) I = keytype(dicts[1]) Ts = Base.Broadcast.eltypes(data) - T = Base.promote_op(f, Ts) + T = Base.promote_op(f, Ts...) return BroadcastedDictionary{I, T, typeof(f), typeof(data)}(f, data, sharetokens) end From 6d3cb9a66e3dbc5a9ddd146d69fb4ac4b1b28d05 Mon Sep 17 00:00:00 2001 From: Oscar Smith Date: Mon, 26 Feb 2024 08:56:28 -0500 Subject: [PATCH 7/8] change broadcast to use Julia's broadcast type promotion --- src/broadcast.jl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/broadcast.jl b/src/broadcast.jl index ad74273..99b47b5 100644 --- a/src/broadcast.jl +++ b/src/broadcast.jl @@ -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 = Base.promote_op(f, Ts...) + T = Base.Broadcast.combine_eltypes(f data) return BroadcastedDictionary{I, T, typeof(f), typeof(data)}(f, data, sharetokens) end From b0a1d3df3b1f24f3e517f4cdf1ea2ccdbc8deb37 Mon Sep 17 00:00:00 2001 From: Oscar Smith Date: Mon, 26 Feb 2024 10:31:42 -0500 Subject: [PATCH 8/8] Update src/broadcast.jl MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Théo Galy-Fajou --- src/broadcast.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/broadcast.jl b/src/broadcast.jl index 99b47b5..26e8d67 100644 --- a/src/broadcast.jl +++ b/src/broadcast.jl @@ -18,7 +18,7 @@ _data(d::BroadcastedDictionary) = getfield(d, :data) dicts = _dicts(data...) sharetokens = _sharetokens(dicts...) I = keytype(dicts[1]) - T = Base.Broadcast.combine_eltypes(f data) + T = Base.Broadcast.combine_eltypes(f, data) return BroadcastedDictionary{I, T, typeof(f), typeof(data)}(f, data, sharetokens) end