Skip to content

Commit 5b8bba6

Browse files
vtjnashmbauman
authored andcommitted
Force specialization on the broadcasteds
1 parent 637a2f2 commit 5b8bba6

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

base/broadcast.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1309,33 +1309,33 @@ macro __dot__(x)
13091309
esc(__dot__(x))
13101310
end
13111311

1312-
@inline function broadcasted_kwsyntax(f, args...; kwargs...)
1312+
@inline function broadcasted_kwsyntax(f::F, args...; kwargs...) where {F}
13131313
if isempty(kwargs) # some BroadcastStyles dispatch on `f`, so try to preserve its type
13141314
return broadcasted(f, args...)
13151315
else
13161316
return broadcasted((args...) -> f(args...; kwargs...), args...)
13171317
end
13181318
end
1319-
@inline function broadcasted(f, args...)
1319+
@inline function broadcasted(f::F, args...) where {F}
13201320
args′ = map(broadcastable, args)
13211321
broadcasted(combine_styles(args′...), f, args′...)
13221322
end
13231323
# Due to the current Type{T}/DataType specialization heuristics within Tuples,
13241324
# the totally generic varargs broadcasted(f, args...) method above loses Type{T}s in
13251325
# mapping broadcastable across the args. These additional methods with explicit
13261326
# arguments ensure we preserve Type{T}s in the first or second argument position.
1327-
@inline function broadcasted(f, arg1, args...)
1327+
@inline function broadcasted(f::F, arg1::T1, args...) where {F, T1}
13281328
arg1′ = broadcastable(arg1)
13291329
args′ = map(broadcastable, args)
13301330
broadcasted(combine_styles(arg1′, args′...), f, arg1′, args′...)
13311331
end
1332-
@inline function broadcasted(f, arg1, arg2, args...)
1332+
@inline function broadcasted(f::F, arg1::T1, arg2::T2, args...) where {F, T1, T2}
13331333
arg1′ = broadcastable(arg1)
13341334
arg2′ = broadcastable(arg2)
13351335
args′ = map(broadcastable, args)
13361336
broadcasted(combine_styles(arg1′, arg2′, args′...), f, arg1′, arg2′, args′...)
13371337
end
1338-
@inline broadcasted(::S, f, args...) where S<:BroadcastStyle = Broadcasted{S}(f, args)
1338+
@inline broadcasted(::S, f::F, args...) where {S<:BroadcastStyle, F} = Broadcasted{S}(f, args)
13391339

13401340
"""
13411341
BroadcastFunction{F} <: Function

0 commit comments

Comments
 (0)