Skip to content

Conversation

NHDaly
Copy link
Member

@NHDaly NHDaly commented Aug 21, 2025

PR Description

Backports JuliaLang#59327.

Original PR description:

Fixes JuliaLang#59326.

Change the logic that decides not to specialize a function parameter based on whether or not the supplied argument is a Function, and that function is not used, so that it will still work if the SpecType is a Union{Function,Nothing} or any other union that contains a Function.

The logic is changed from a hardcoded rule of type_i == Function || type_i == Any || type_i == Base.Callable to type_i >: Function.

This covers all of the above cases, but also includes custom Union{Function, T} such as Union{Function, Nothing}.

Checklist

Requirements for merging:

…iaLang#59327)

Fixes JuliaLang#59326.

Change the logic that decides not to specialize a function parameter
based on whether or not the supplied argument is a Function, and that
function is not used, so that it will still work if the SpecType is a
Union{Function,Nothing} or any other union that contains a Function.

The logic is changed from a hardcoded rule of `type_i == Function ||
type_i == Any || type_i == Base.Callable` to `type_i >: Function`.

This covers all of the above cases, but also includes custom
`Union{Function, T}` such as `Union{Function, Nothing}`.

---------

Co-authored-by: Nick Robinson <[email protected]>
Co-authored-by: Jameson Nash <[email protected]>
@NHDaly NHDaly added port-to-v1.12 This change should apply to Julia v1.12 builds port-to-v1.10 labels Aug 21, 2025
@NHDaly NHDaly merged commit 061a139 into v1.10.2+RAI Aug 26, 2025
4 checks passed
@NHDaly NHDaly deleted the nhd-backport-59327 branch August 26, 2025 16:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
port-to-v1.12 This change should apply to Julia v1.12 builds
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Method parameter type annotation Union{Function, Nothing} causes incorrect specialization on concrete Function type
2 participants