Skip to content

Commit b688db5

Browse files
vtjnashmbauman
authored andcommitted
Force specialization on the broadcasteds
1 parent cf180f1 commit b688db5

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
@@ -1293,27 +1293,27 @@ macro __dot__(x)
12931293
esc(__dot__(x))
12941294
end
12951295

1296-
@inline broadcasted_kwsyntax(f, args...; kwargs...) = broadcasted((args...)->f(args...; kwargs...), args...)
1297-
@inline function broadcasted(f, args...)
1296+
@inline broadcasted_kwsyntax(f::F, args...; kwargs...) where {F} = broadcasted((args...)->f(args...; kwargs...), args...)
1297+
@inline function broadcasted(f::F, args...) where {F}
12981298
args′ = map(broadcastable, args)
12991299
broadcasted(combine_styles(args′...), f, args′...)
13001300
end
13011301
# Due to the current Type{T}/DataType specialization heuristics within Tuples,
13021302
# the totally generic varargs broadcasted(f, args...) method above loses Type{T}s in
13031303
# mapping broadcastable across the args. These additional methods with explicit
13041304
# arguments ensure we preserve Type{T}s in the first or second argument position.
1305-
@inline function broadcasted(f, arg1, args...)
1305+
@inline function broadcasted(f::F, arg1::T1, args...) where {F, T1}
13061306
arg1′ = broadcastable(arg1)
13071307
args′ = map(broadcastable, args)
13081308
broadcasted(combine_styles(arg1′, args′...), f, arg1′, args′...)
13091309
end
1310-
@inline function broadcasted(f, arg1, arg2, args...)
1310+
@inline function broadcasted(f::F, arg1::T1, arg2::T2, args...) where {F, T1, T2}
13111311
arg1′ = broadcastable(arg1)
13121312
arg2′ = broadcastable(arg2)
13131313
args′ = map(broadcastable, args)
13141314
broadcasted(combine_styles(arg1′, arg2′, args′...), f, arg1′, arg2′, args′...)
13151315
end
1316-
@inline broadcasted(::S, f, args...) where S<:BroadcastStyle = Broadcasted{S}(f, args)
1316+
@inline broadcasted(::S, f::F, args...) where {S<:BroadcastStyle, F} = Broadcasted{S}(f, args)
13171317

13181318
"""
13191319
BroadcastFunction{F} <: Function

0 commit comments

Comments
 (0)