@@ -1093,22 +1093,22 @@ end
1093
1093
# 15995
1094
1094
@deprecate symbol Symbol
1095
1095
1096
- # 15032: Expressions like Base.(:+) now call broadcast. Since there is unlikely
1097
- # to be any legitimate reason to broadcast to a Module (not iterable!),
1098
- # it should be safe to catch this with a deprecation method.
1099
- # Note: this deprecation does not handle method definitions Base.(:+)(...) = ...,
1100
- # which are handled by the deprecate-dotparen function in julia-syntax.scm
1101
- # More generally, expressions like x.(sym) for any Symbol turn into broadcast
1102
- # but should really be getfield, and since you can't broadcast to a symbol
1103
- # using a deprecated broadcast method should be safe. [Unfortunately,
1104
- # we can't catch x.(i::Int) in the same way, because broadcasting to an
1105
- # integer is a valid use of broadcast Most such usages will simply
1106
- # give an error, since x is probably not callable if getfield was intended.]
1096
+ # 15032: Expressions like Base.(:+) now call broadcast. Since calls
1097
+ # to broadcast(x, ::Symbol) are unheard of, and broadcast(x, ::Integer)
1098
+ # are unlikely, we can treat these as deprecated getfield calls.
1099
+ function broadcast (x:: Any , i:: Union{Integer,Symbol} )
1100
+ depwarn (" x.(i) is deprecated; use getfield(x, i) instead." , :broadcast )
1101
+ getfield (x, i)
1102
+ end
1103
+ # clearer to be more explicit in the warning for the Module case
1107
1104
function broadcast (m:: Module , s:: Symbol )
1108
1105
depwarn (" $m .(:$s ) is deprecated; use $m .:$s or getfield($m , :$s ) instead." , :broadcast )
1109
1106
getfield (m, s)
1110
1107
end
1111
- @deprecate broadcast (x:: Any , s:: Symbol ) getfield (x, s)
1108
+ # expressions like f.(3) should still call broadcast for f::Function,
1109
+ # and in general broadcast should work for scalar arguments, while
1110
+ # getfield is certainly not intended for the case of f::Function.
1111
+ broadcast (f:: Function , i:: Integer ) = invoke (broadcast, (Function, Number), f, i)
1112
1112
1113
1113
# 16167
1114
1114
macro ccallable (def)
0 commit comments