Loop through subtypes

In what way is subtypes(T) insufficient?

Edit: I mean you already provided an implementation, no?

julia> abstract type Parent end

julia> struct T1 <: Parent end

julia> struct T2 <: Parent end

julia> has_feature(::Type{<:Parent}) = false
has_feature (generic function with 1 method)

julia> has_feature(::Type{T1}) = true
has_feature (generic function with 2 methods)

julia> for Ti in subtypes(Parent)
           @info Ti has_feature(Ti)
       end
┌ Info: T1
└   has_feature(Ti) = true
┌ Info: T2
└   has_feature(Ti) = false

3 Likes