Skip to content

Commit

Permalink
Relax type restriction in ismutationfree and isidentityfree. (#48357)
Browse files Browse the repository at this point in the history
Fixes #48353.
  • Loading branch information
Keno committed Jan 24, 2023
1 parent 134f3e7 commit b8adb2e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions base/reflection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -634,13 +634,14 @@ is reachable from this type (either in the type itself) or through any fields.
Note that the type itself need not be immutable. For example, an empty mutable
type is `ismutabletype`, but also `ismutationfree`.
"""
function ismutationfree(@nospecialize(t::Type))
function ismutationfree(@nospecialize(t))
t = unwrap_unionall(t)
if isa(t, DataType)
return datatype_ismutationfree(t)
elseif isa(t, Union)
return ismutationfree(t.a) && ismutationfree(t.b)
end
# TypeVar, etc.
return false
end

Expand All @@ -652,7 +653,7 @@ datatype_isidentityfree(dt::DataType) = (@_total_meta; (dt.flags & 0x0200) == 0x
Determine whether type `T` is identity free in the sense that this type or any
reachable through its fields has non-content-based identity.
"""
function isidentityfree(@nospecialize(t::Type))
function isidentityfree(@nospecialize(t))
t = unwrap_unionall(t)
if isa(t, DataType)
return datatype_isidentityfree(t)
Expand Down

0 comments on commit b8adb2e

Please sign in to comment.