Skip to content

Commit 8f347ad

Browse files
fix: make promotion change non-breaking
Co-authored-by: Benoît Legat <[email protected]>
1 parent e15db31 commit 8f347ad

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

src/interface.jl

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,22 +40,34 @@ function promote_operation_fallback(
4040
::Type{S},
4141
::Type{T},
4242
) where {S,T}
43-
return typeof(op(_instantiate_zero(S), _instantiate_oneunit(T)))
43+
if isconcretetype(S) && isconcretetype(T)
44+
return typeof(op(_instantiate_zero(S), _instantiate_oneunit(T)))
45+
else
46+
return promote_type(S, T)
47+
end
4448
end
4549

4650
function promote_operation_fallback(
4751
op::F,
4852
::Type{S},
4953
::Type{T},
5054
) where {F<:Function,S,T}
51-
return typeof(op(_instantiate_zero(S), _instantiate_zero(T)))
55+
if isconcretetype(S) && isconcretetype(T)
56+
return typeof(op(_instantiate_zero(S), _instantiate_zero(T)))
57+
else
58+
return promote_type(S, T)
59+
end
5260
end
5361

5462
function promote_operation_fallback(
55-
::F,
63+
op::F,
5664
args::Vararg{Type,N},
5765
) where {F<:Function,N}
58-
return typeof(op(_instantiate_zero.(args)...))
66+
if all(isconcretetype, args)
67+
return typeof(op(_instantiate_zero.(args)...))
68+
else
69+
return promote_type(args...)
70+
end
5971
end
6072

6173
promote_operation_fallback(::typeof(*), ::Type{T}) where {T} = T

0 commit comments

Comments
 (0)