@@ -100,7 +100,9 @@ Finally, the same behavior is obtained when the keyword arguments are
100100passed as the third positional argument in the form of a `NamedTuple`.
101101""" select_algorithm
102102
103- @inline function select_algorithm (f:: F , A, alg:: Alg = nothing ; kwargs... ) where {F, Alg}
103+ # WARNING: In order to keep everything type stable, this function is marked as foldable.
104+ # This mostly means that the `default_algorithm` implementation must be foldable as well
105+ Base. @assume_effects :foldable function select_algorithm (f:: F , A, alg:: Alg = nothing ; kwargs... ) where {F, Alg}
104106 if isnothing (alg)
105107 return default_algorithm (f, A; kwargs... )
106108 elseif alg isa Symbol
@@ -129,8 +131,10 @@ In general, this is called by [`select_algorithm`](@ref) if no algorithm is spec
129131explicitly.
130132New types should prefer to register their default algorithms in the type domain.
131133""" default_algorithm
132- default_algorithm (f:: F , A; kwargs... ) where {F} = default_algorithm (f, typeof (A); kwargs... )
133- default_algorithm (f:: F , A, B; kwargs... ) where {F} = default_algorithm (f, typeof (A), typeof (B); kwargs... )
134+ @inline default_algorithm (f:: F , A; kwargs... ) where {F} =
135+ default_algorithm (f, typeof (A); kwargs... )
136+ @inline default_algorithm (f:: F , A, B; kwargs... ) where {F} =
137+ default_algorithm (f, typeof (A), typeof (B); kwargs... )
134138# avoid infinite recursion:
135139function default_algorithm (f:: F , :: Type{T} ; kwargs... ) where {F, T}
136140 throw (MethodError (default_algorithm, (f, T)))
0 commit comments