@@ -309,7 +309,12 @@ get_types(["Base", "Core"]) # returns type names from both packages
309309function get_types (modul:: Module )
310310 types = []
311311 for name ∈ names (modul)
312- if isdefined (modul, name) && getfield (modul, name) isa DataType
312+ if isdefined (modul, name) && (
313+ getfield (modul, name) isa DataType || (
314+ getfield (modul, name) isa UnionAll &&
315+ Base. unwrap_unionall (getfield (modul, name)) isa DataType
316+ )
317+ )
313318 push! (types, name)
314319 end
315320 end
@@ -368,7 +373,12 @@ This set of functions helps extract the inheritance hierarchy of types defined i
368373function get_supertypes (modul:: Module )
369374 types= Dict ()
370375 for name ∈ names (modul)
371- if isdefined (modul, name) && getfield (modul, name) isa DataType
376+ if isdefined (modul, name) && (
377+ getfield (modul, name) isa DataType || (
378+ getfield (modul, name) isa UnionAll &&
379+ Base. unwrap_unionall (getfield (modul, name)) isa DataType
380+ )
381+ )
372382 types[name] = supertypes (getfield (modul, name))
373383 end
374384 end
@@ -410,7 +420,6 @@ Checks whether a given type is a concrete struct with at least one field.
410420
411421# Description
412422This function combines three checks:
413- - `isconcretetype(type)`: Ensures the type is concrete (i.e., can be instantiated).
414423- `isstructtype(type)`: Ensures the type is a struct.
415424- `nfields(type) > 0`: Ensures the struct has at least one field.
416425
@@ -427,7 +436,8 @@ has_fields(AbstractType) # returns false
427436```
428437"""
429438function has_fields (type)
430- return (isconcretetype (type) && isstructtype (type) && nfields (type) > 0 )
439+ t = type isa UnionAll ? Base. unwrap_unionall (type) : type
440+ return (t isa DataType && isstructtype (t) && nfields (t) > 0 )
431441end
432442
433443"""
0 commit comments