Skip to content

Commit

Permalink
anymutable should ignore fields that refer to parent type
Browse files Browse the repository at this point in the history
  • Loading branch information
oschulz committed Feb 6, 2024
1 parent 19788ea commit 51ba0be
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/walks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,10 @@ usecache(::Union{AbstractDict, AbstractSet}, x) =
isleaf(x) ? anymutable(x) : ismutable(x)
usecache(::Nothing, x) = false

@generated function anymutable(x::T) where {T}
@generated function Functors.anymutable(x::T) where {T}
ismutabletype(T) && return true
subs = [:(anymutable(getfield(x, $f))) for f in QuoteNode.(fieldnames(T))]
fns = QuoteNode.(filter(n -> fieldtype(T, n) != T, fieldnames(T)))
subs = [:(anymutable(getfield(x, $f))) for f in fns]
return Expr(:(||), subs...)
end

Expand Down

0 comments on commit 51ba0be

Please sign in to comment.