Skip to content

Commit 2656cdb

Browse files
committed
rename isimmutabletype to just a method of isimmutable
1 parent 13859b7 commit 2656cdb

File tree

4 files changed

+13
-20
lines changed

4 files changed

+13
-20
lines changed

NEWS.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,9 @@ This section lists changes that do not have deprecation warnings.
130130
(since it is shorthand for `NTuple{N,T} where T`). To get the old behavior of matching
131131
any tuple, use `NTuple{N,Any}` ([#18457]).
132132

133+
* `isimmutable(T::Type)` now checks whether `T` is an immutable type,
134+
rather than checking whether `typeof(T)` is an immutable type ([#18168]).
135+
133136
Library improvements
134137
--------------------
135138

@@ -210,8 +213,6 @@ Library improvements
210213

211214
* New `iszero(x)` function to quickly check whether `x` is zero (or is all zeros, for an array) ([#19950]).
212215

213-
* New function `isimmutabletype(T)` ([#18168]).
214-
215216
* `notify` now returns a count of tasks woken up ([#19841]).
216217

217218
Compiler/Runtime improvements

base/exports.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -946,7 +946,6 @@ export
946946
isbits,
947947
isequal,
948948
isimmutable,
949-
isimmutabletype,
950949
isless,
951950
ifelse,
952951
lexless,

base/reflection.jl

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -195,25 +195,18 @@ datatype_fielddesc_type(dt::DataType) = dt.layout == C_NULL ? throw(UndefRefErro
195195
(unsafe_load(convert(Ptr{DataTypeLayout}, dt.layout)).alignment >> 30) & 3
196196

197197
"""
198-
isimmutable(v)
198+
isimmutable(x)
199199
200-
Return `true` iff value `v` is immutable. See [Immutable Composite Types](@ref)
201-
for a discussion of immutability. Note that this function works on values, so if you give it
202-
a type, it will tell you that a value of `DataType` is mutable.
200+
Return `true` if the value `x` is immutable; if `x` is a type, then returns
201+
whether `x` is an immutable type. See [Immutable Composite Types](@ref)
202+
for a discussion of immutability.
203203
"""
204204
isimmutable(x::ANY) = (@_pure_meta; (isa(x,Tuple) || !typeof(x).mutable))
205+
isimmutable(t::DataType) = (@_pure_meta; !t.mutable)
206+
isimmutable(::Type) = (@_pure_meta; false)
205207
isstructtype(t::DataType) = (@_pure_meta; nfields(t) != 0 || (t.size==0 && !t.abstract))
206208
isstructtype(x) = (@_pure_meta; false)
207209

208-
"""
209-
isimmutabletype(T)
210-
211-
Return `true` if the type `T` is immutable. See [manual](:ref:`man-immutable-composite-types`)
212-
for a discussion of immutability. See also [`isimmutable`](:func:`isimmutable`)
213-
for the corresponding function acting on values rather than types.
214-
"""
215-
isimmutabletype(t::ANY) = (@_pure_meta; isa(t, DataType) && !t.mutable)
216-
217210
"""
218211
isbits(T)
219212

test/reflection.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,10 @@ not_const = 1
161161
@test isimmutable([]) == false
162162
@test isimmutable("abc") == true
163163
@test isimmutable((3,4,5)) == true
164-
@test isimmutabletype(Int) == true
165-
@test isimmutabletype(Vector{Int}) == false
166-
@test isimmutabletype(String) == true
167-
@test isimmutabletype(Tuple{Int}) == true
164+
@test isimmutable(Int) == true
165+
@test isimmutable(Vector{Int}) == false
166+
@test isimmutable(String) == true
167+
@test isimmutable(Tuple{Int}) == true
168168

169169

170170
## find bindings tests

0 commit comments

Comments
 (0)