@@ -287,28 +287,36 @@ isbits(t::DataType) = (@_pure_meta; !t.mutable & (t.layout != C_NULL) && datatyp
287
287
isbits (t:: Type ) = (@_pure_meta ; false )
288
288
isbits (x) = (@_pure_meta ; isbits (typeof (x)))
289
289
290
+ _isleaftype (@nospecialize (t)) = (@_pure_meta ; isa (t, DataType) && t. isleaftype)
291
+
290
292
"""
291
- isleaftype (T)
293
+ isconcrete (T)
292
294
293
- Determine whether `T`'s only subtypes are itself and `Union{}`. This means `T` is
294
- a concrete type that can have instances .
295
+ Determine whether `T` is a concrete type, meaning it can have direct instances
296
+ (values `x` such that `typeof(x) === T`) .
295
297
296
298
# Examples
297
299
```jldoctest
298
- julia> isleaftype (Complex)
300
+ julia> isconcrete (Complex)
299
301
false
300
302
301
- julia> isleaftype (Complex{Float32})
303
+ julia> isconcrete (Complex{Float32})
302
304
true
303
305
304
- julia> isleaftype (Vector{Complex})
306
+ julia> isconcrete (Vector{Complex})
305
307
true
306
308
307
- julia> isleaftype (Vector{Complex{Float32}})
309
+ julia> isconcrete (Vector{Complex{Float32}})
308
310
true
311
+
312
+ julia> isconcrete(Union{})
313
+ false
314
+
315
+ julia> isconcrete(Union{Int,String})
316
+ false
309
317
```
310
318
"""
311
- isleaftype (@nospecialize (t)) = (@_pure_meta ; isa (t, DataType) && t. isleaftype )
319
+ isconcrete (@nospecialize (t)) = (@_pure_meta ; isa (t, DataType) && t. layout != C_NULL )
312
320
313
321
"""
314
322
Base.isabstract(T)
@@ -791,7 +799,7 @@ function _dump_function_linfo(linfo::Core.MethodInstance, world::UInt, native::B
791
799
end
792
800
793
801
# TODO : use jl_is_cacheable_sig instead of isleaftype
794
- isleaftype (linfo. specTypes) || (str = " ; WARNING: This code may not match what actually runs.\n " * str)
802
+ _isleaftype (linfo. specTypes) || (str = " ; WARNING: This code may not match what actually runs.\n " * str)
795
803
return str
796
804
end
797
805
@@ -822,7 +830,7 @@ code_native(::IO, ::Any, ::Symbol) = error("illegal code_native call") # resolve
822
830
823
831
# give a decent error message if we try to instantiate a staged function on non-leaf types
824
832
function func_for_method_checked (m:: Method , @nospecialize types)
825
- if isdefined (m,:generator ) && ! isdefined (m,:source ) && ! isleaftype (types)
833
+ if isdefined (m,:generator ) && ! isdefined (m,:source ) && ! _isleaftype (types)
826
834
error (" cannot call @generated function `" , m, " ` " ,
827
835
" with abstract argument types: " , types)
828
836
end
0 commit comments