Skip to content

Commit 1cc730c

Browse files
committed
Add tests for (lack of) specialization
1 parent f12a211 commit 1cc730c

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

test/core.jl

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,36 @@ k11840(::Type{Union{Tuple{Int32}, Tuple{Int64}}}) = '2'
243243
@test k11840(Tuple{Union{Int32, Int64}}) == '2'
244244
@test k11840(Union{Tuple{Int32}, Tuple{Int64}}) == '2'
245245

246+
# issue #59327
247+
@noinline f59327(f, x) = Any[f, x]
248+
g59327(x) = f59327(+, Any[x][1])
249+
g59327(1)
250+
@test any(
251+
mi->mi isa Core.MethodInstance && mi.specTypes == Tuple{typeof(f59327), Function, Int64},
252+
methods(f59327)[1].specializations)
253+
254+
@noinline h59327(f::Union{Function, Nothing}, x) = Any[f, x]
255+
i59327(x) = h59327(+, Any[x][1])
256+
i59327(1)
257+
@test any(
258+
mi->mi isa Core.MethodInstance && mi.specTypes == Tuple{typeof(h59327), Function, Int64},
259+
methods(h59327)[1].specializations)
260+
261+
@noinline j59327(f::Function, x) = Any[f, x]
262+
k59327(x) = j59327(+, Any[x][1])
263+
k59327(1)
264+
@test any(
265+
mi->mi isa Core.MethodInstance && mi.specTypes == Tuple{typeof(j59327), Function, Int64},
266+
methods(j59327)[1].specializations
267+
)
268+
269+
@noinline k59327(f::Base.Callable, x) = Any[f, x]
270+
l59327(x) = k59327(+, Any[x][1])
271+
l59327(1)
272+
@test any(
273+
mi->mi isa Core.MethodInstance && mi.specTypes == Tuple{typeof(k59327), Function, Int64},
274+
methods(k59327)[1].specializations
275+
)
246276

247277
# issue #20511
248278
f20511(x::DataType) = 0

0 commit comments

Comments
 (0)