From 800b9d482002c9e3e2010f9e3bed13d8618c6c65 Mon Sep 17 00:00:00 2001 From: Jishnu Bhattacharya Date: Sun, 8 Dec 2024 20:20:20 +0530 Subject: [PATCH] Update comment above `promote_result` --- base/promotion.jl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/base/promotion.jl b/base/promotion.jl index 8899492892824..3a74930fceeca 100644 --- a/base/promotion.jl +++ b/base/promotion.jl @@ -331,9 +331,11 @@ promote_rule(::Type{Bottom}, ::Type{Bottom}, slurp...) = Bottom # not strictly n promote_rule(::Type{Bottom}, ::Type{T}, slurp...) where {T} = T promote_rule(::Type{T}, ::Type{Bottom}, slurp...) where {T} = T +# if both the arguments are identical, or if both the orderings in promote_rule +# are defined to return identical results, we may return the result directly promote_result(::Type{T},::Type{T},::Type{T},::Type{T}) where {T} = T -# If only one promote_rule is defined, use the definition directly promote_result(::Type,::Type,::Type{T},::Type{T}) where {T} = T +# If only one promote_rule is defined, use the definition directly promote_result(::Type,::Type,::Type{T},::Type{Bottom}) where {T} = T promote_result(::Type,::Type,::Type{Bottom},::Type{T}) where {T} = T # if multiple promote_rules are defined, try to promote the results