@@ -127,9 +127,9 @@ promote_type(T) = (@_pure_meta; T)
127
127
promote_type (T, S, U, V... ) = (@_pure_meta ; promote_type (T, promote_type (S, U, V... )))
128
128
129
129
promote_type (:: Type{Bottom} , :: Type{Bottom} ) = (@_pure_meta ; Bottom)
130
- promote_type {T} (:: Type{T} , :: Type{T} ) = (@_pure_meta ; T)
131
- promote_type {T} (:: Type{T} , :: Type{Bottom} ) = (@_pure_meta ; T)
132
- promote_type {T} (:: Type{Bottom} , :: Type{T} ) = (@_pure_meta ; T)
130
+ promote_type (:: Type{T} , :: Type{T} ) where {T} = (@_pure_meta ; T)
131
+ promote_type (:: Type{T} , :: Type{Bottom} ) where {T} = (@_pure_meta ; T)
132
+ promote_type (:: Type{Bottom} , :: Type{T} ) where {T} = (@_pure_meta ; T)
133
133
134
134
"""
135
135
promote_type(type1, type2)
@@ -166,7 +166,7 @@ promote_rule(T, S) = (@_pure_meta; Bottom)
166
166
promote_result (t,s,T,S) = (@_pure_meta ; promote_type (T,S))
167
167
# If no promote_rule is defined, both directions give Bottom. In that
168
168
# case use typejoin on the original types instead.
169
- promote_result {T,S} (:: Type{T} ,:: Type{S} ,:: Type{Bottom} ,:: Type{Bottom} ) = (@_pure_meta ; typejoin (T, S))
169
+ promote_result (:: Type{T} ,:: Type{S} ,:: Type{Bottom} ,:: Type{Bottom} ) where {T,S} = (@_pure_meta ; typejoin (T, S))
170
170
171
171
promote () = ()
172
172
promote (x) = (x,)
@@ -194,18 +194,18 @@ end
194
194
# Otherwise, typejoin(T,S) is called (returning Number) so no conversion
195
195
# happens, and +(promote(x,y)...) is called again, causing a stack
196
196
# overflow.
197
- function promote_result {T<:Number,S<:Number} (:: Type{T} ,:: Type{S} ,:: Type{Bottom} ,:: Type{Bottom} )
197
+ function promote_result (:: Type{T} ,:: Type{S} ,:: Type{Bottom} ,:: Type{Bottom} ) where {T <: Number ,S <: Number }
198
198
@_pure_meta
199
199
promote_to_supertype (T, S, typejoin (T,S))
200
200
end
201
201
202
202
# promote numeric types T and S to typejoin(T,S) if T<:S or S<:T
203
203
# for example this makes promote_type(Integer,Real) == Real without
204
204
# promoting arbitrary pairs of numeric types to Number.
205
- promote_to_supertype {T<:Number } (:: Type{T} , :: Type{T} , :: Type{T} ) = (@_pure_meta ; T)
206
- promote_to_supertype {T<:Number,S<:Number} (:: Type{T} , :: Type{S} , :: Type{T} ) = (@_pure_meta ; T)
207
- promote_to_supertype {T<:Number,S<:Number} (:: Type{T} , :: Type{S} , :: Type{S} ) = (@_pure_meta ; S)
208
- promote_to_supertype {T<:Number,S<:Number} (:: Type{T} , :: Type{S} , :: Type ) =
205
+ promote_to_supertype (:: Type{T} , :: Type{T} , :: Type{T} ) where {T <: Number } = (@_pure_meta ; T)
206
+ promote_to_supertype (:: Type{T} , :: Type{S} , :: Type{T} ) where {T <: Number ,S <: Number } = (@_pure_meta ; T)
207
+ promote_to_supertype (:: Type{T} , :: Type{S} , :: Type{S} ) where {T <: Number ,S <: Number } = (@_pure_meta ; S)
208
+ promote_to_supertype (:: Type{T} , :: Type{S} , :: Type ) where {T <: Number ,S <: Number } =
209
209
error (" no promotion exists for " , T, " and " , S)
210
210
211
211
# promotion with a check for circularity. Can be used to catch what
@@ -229,9 +229,9 @@ function promote_noncircular(x, y, z, a...)
229
229
end
230
230
not_all_sametype (x, y) = nothing
231
231
not_all_sametype (x, y, z) = nothing
232
- not_all_sametype {S,T} (x:: Tuple{S,S} , y:: Tuple{T,T} ) = sametype_error (x[1 ], y[1 ])
233
- not_all_sametype {R,S,T} (x:: Tuple{R,R} , y:: Tuple{S,S} , z:: Tuple{T,T} ) = sametype_error (x[1 ], y[1 ], z[1 ])
234
- function not_all_sametype {R,S,T} (:: Tuple{R,R} , y:: Tuple{S,S} , z:: Tuple{T,T} , args... )
232
+ not_all_sametype (x:: Tuple{S,S} , y:: Tuple{T,T} ) where {S,T} = sametype_error (x[1 ], y[1 ])
233
+ not_all_sametype (x:: Tuple{R,R} , y:: Tuple{S,S} , z:: Tuple{T,T} ) where {R,S,T} = sametype_error (x[1 ], y[1 ], z[1 ])
234
+ function not_all_sametype (:: Tuple{R,R} , y:: Tuple{S,S} , z:: Tuple{T,T} , args... ) where {R,S,T}
235
235
@_inline_meta
236
236
not_all_sametype (y, z, args... )
237
237
end
0 commit comments