Skip to content

Commit 2ab926b

Browse files
committed
Fix specialization of Base.return_types
1 parent c6d1e12 commit 2ab926b

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ This page describes the most important changes in `TypeUtils`. The format is bas
1919

2020
- Better rule for element type conversion of `AbstractUnitRange` instances.
2121

22+
- Fix specialization of `Base.return_types` which shall return a vector of types.
23+
2224

2325
## Version 1.7.1 (2025-05-19)
2426

src/funcs.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,7 @@ AbstractTypeStableFunction{T}(f) where {T} = TypeStableFunction{T}(f)
6666
# Extend base methods.
6767
Base.parent(obj::TypeStableFunction) = getfield(obj, :callable)
6868

69-
Base.return_types(::AbstractTypeStableFunction{T}; kwds...) where {T} = (T,)
70-
Base.return_types(::AbstractTypeStableFunction{T}, ::DataType; kwds...) where {T} = (T,)
69+
Base.return_types(::AbstractTypeStableFunction{T}, ::Any=Tuple) where {T} = [T]
7170

7271
Base.promote_op(::AbstractTypeStableFunction{T}, ::DataType...) where {T} = T
7372

test/runtests.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -544,8 +544,8 @@ same_value_and_type(x::T, y::T) where {T} = (x === y) || (x == y)
544544
@test return_type(g) === BigFloat
545545
@test return_type(typeof(f)) === Float32
546546
@test return_type(typeof(g)) === BigFloat
547-
@test Base.return_types(f) === (return_type(f),)
548-
@test Base.return_types(g) === (return_type(g),)
547+
@test Base.return_types(f) == [return_type(f)]
548+
@test Base.return_types(g, Tuple) == [return_type(g)]
549549
@test Base.promote_op(f, Int8) === return_type(f)
550550
@test Base.promote_op(f, Int8, Int16) === return_type(f)
551551
@test Base.promote_op(g, Float32) === return_type(g)

0 commit comments

Comments
 (0)