@@ -233,6 +233,62 @@ k11840(::Type{Union{Tuple{Int32}, Tuple{Int64}}}) = '2'
233233@test k11840 (Tuple{Union{Int32, Int64}}) == ' 2'
234234@test k11840 (Union{Tuple{Int32}, Tuple{Int64}}) == ' 2'
235235
236+ # issue #59327
237+ @noinline f59327 (f, x) = Any[f, x]
238+ g59327 (x) = f59327 (+ , Any[x][1 ])
239+ g59327 (1 )
240+ @test any (
241+ mi-> mi isa Core. MethodInstance && mi. specTypes == Tuple{typeof (f59327), Function, Int},
242+ methods (f59327)[1 ]. specializations)
243+
244+ @noinline h59327 (f:: Union{Function, Nothing} , x) = Any[f, x]
245+ i59327 (x) = h59327 (+ , Any[x][1 ])
246+ i59327 (1 )
247+ @test any (
248+ mi-> mi isa Core. MethodInstance && mi. specTypes == Tuple{typeof (h59327), Function, Int},
249+ methods (h59327)[1 ]. specializations)
250+
251+ @noinline j59327 (f:: Function , x) = Any[f, x]
252+ k59327 (x) = j59327 (+ , Any[x][1 ])
253+ k59327 (1 )
254+ @test any (
255+ mi-> mi isa Core. MethodInstance && mi. specTypes == Tuple{typeof (j59327), Function, Int},
256+ methods (j59327)[1 ]. specializations
257+ )
258+
259+ @noinline l59327 (f:: Base.Callable , x) = Any[f, x]
260+ m59327 (x) = l59327 (+ , Any[x][1 ])
261+ m59327 (1 )
262+ @test any (
263+ mi-> mi isa Core. MethodInstance && mi. specTypes == Tuple{typeof (l59327), Function, Int},
264+ methods (l59327)[1 ]. specializations
265+ )
266+
267+ # _do_ specialize if the signature has a `where`
268+ @noinline n59327 (f:: F , x) where F = Any[f, x]
269+ o59327 (x) = n59327 (+ , Any[x][1 ])
270+ o59327 (1 )
271+ @test ! any (
272+ mi-> mi isa Core. MethodInstance && mi. specTypes == Tuple{typeof (n59327), Function, Int},
273+ methods (n59327)[1 ]. specializations
274+ )
275+ @test any (
276+ mi-> mi isa Core. MethodInstance && mi. specTypes == Tuple{typeof (n59327), typeof (+ ), Int},
277+ methods (n59327)[1 ]. specializations
278+ )
279+
280+ # _do_ specialize if the signature is specific
281+ @noinline n59327 (f:: typeof (+ ), x) = Any[f, x]
282+ o59327 (x) = n59327 (+ , Any[x][1 ])
283+ o59327 (1 )
284+ @test ! any (
285+ mi-> mi isa Core. MethodInstance && mi. specTypes == Tuple{typeof (n59327), Function, Int},
286+ methods (n59327)[1 ]. specializations
287+ )
288+ @test any (
289+ mi-> mi isa Core. MethodInstance && mi. specTypes == Tuple{typeof (n59327), typeof (+ ), Int},
290+ methods (n59327)[1 ]. specializations
291+ )
236292
237293# issue #20511
238294f20511 (x:: DataType ) = 0
0 commit comments