@@ -347,7 +347,7 @@ const _Type_name = Type.body.name
347
347
isType (t:: ANY ) = isa (t, DataType) && (t:: DataType ). name === _Type_name
348
348
349
349
# true if Type is inlineable as constant (is a singleton)
350
- isconstType (t:: ANY ) = isType (t) && (isleaftype (t. parameters[1 ]) || t. parameters[1 ] === Union{})
350
+ isconstType (t:: ANY ) = isType (t) && (isconcrete (t. parameters[1 ]) || t. parameters[1 ] === Union{})
351
351
352
352
const IInf = typemax (Int) # integer infinity
353
353
const n_ifunc = reinterpret (Int32,arraylen)+ 1
@@ -544,7 +544,7 @@ add_tfunc(nfields, 1, 1,
544
544
isa (x,Const) && return Const (nfields (x. val))
545
545
isa (x,Conditional) && return Const (nfields (Bool))
546
546
if isType (x)
547
- isleaftype (x. parameters[1 ]) && return Const (nfields (x. parameters[1 ]))
547
+ isconcrete (x. parameters[1 ]) && return Const (nfields (x. parameters[1 ]))
548
548
elseif isa (x,DataType) && ! x. abstract && ! (x. name === Tuple. name && isvatuple (x))
549
549
return Const (length (x. types))
550
550
end
@@ -578,13 +578,13 @@ function typeof_tfunc(t::ANY)
578
578
return Const (Bool)
579
579
elseif isType (t)
580
580
tp = t. parameters[1 ]
581
- if ! isleaftype (tp)
581
+ if ! isconcrete (tp)
582
582
return DataType # typeof(Kind::Type)::DataType
583
583
else
584
584
return Const (typeof (tp)) # XXX : this is not necessarily true
585
585
end
586
586
elseif isa (t, DataType)
587
- if isleaftype (t) || isvarargtype (t)
587
+ if isconcrete (t) || isvarargtype (t)
588
588
return Const (t)
589
589
elseif t === Any
590
590
return DataType
@@ -625,11 +625,11 @@ add_tfunc(isa, 2, 2,
625
625
if t != = Any && ! has_free_typevars (t)
626
626
if v ⊑ t
627
627
return Const (true )
628
- elseif isa (v, Const) || isa (v, Conditional) || isleaftype (v)
628
+ elseif isa (v, Const) || isa (v, Conditional) || isconcrete (v)
629
629
return Const (false )
630
630
end
631
631
end
632
- # TODO : handle non-leaftype(t) by testing against lower and upper bounds
632
+ # TODO : handle non-concrete t by testing against lower and upper bounds
633
633
return Bool
634
634
end )
635
635
add_tfunc (issubtype, 2 , 2 ,
@@ -739,7 +739,7 @@ function getfield_tfunc(s00::ANY, name)
739
739
s = unwrap_unionall (s00)
740
740
if isType (s)
741
741
p1 = s. parameters[1 ]
742
- if ! isleaftype (p1)
742
+ if ! isconcrete (p1)
743
743
return Any
744
744
end
745
745
s = DataType # typeof(p1)
@@ -826,7 +826,7 @@ function getfield_tfunc(s00::ANY, name)
826
826
if fld < 1 || fld > nf
827
827
return Bottom
828
828
end
829
- if isType (s00) && isleaftype (s00. parameters[1 ])
829
+ if isType (s00) && isconcrete (s00. parameters[1 ])
830
830
sp = s00. parameters[1 ]
831
831
elseif isa (s00, Const) && isa (s00. val, DataType)
832
832
sp = s00. val
@@ -926,7 +926,7 @@ has_free_typevars(t::ANY) = ccall(:jl_has_free_typevars, Cint, (Any,), t)!=0
926
926
function apply_type_tfunc (headtypetype:: ANY , args:: ANY... )
927
927
if isa (headtypetype, Const)
928
928
headtype = headtypetype. val
929
- elseif isType (headtypetype) && isleaftype (headtypetype. parameters[1 ])
929
+ elseif isType (headtypetype) && isconcrete (headtypetype. parameters[1 ])
930
930
headtype = headtypetype. parameters[1 ]
931
931
else
932
932
return Any
@@ -949,7 +949,7 @@ function apply_type_tfunc(headtypetype::ANY, args::ANY...)
949
949
ai = args[i]
950
950
if isType (ai)
951
951
aty = ai. parameters[1 ]
952
- isleaftype (aty) || (allconst = false )
952
+ isconcrete (aty) || (allconst = false )
953
953
else
954
954
aty = (ai:: Const ). val
955
955
end
@@ -970,7 +970,7 @@ function apply_type_tfunc(headtypetype::ANY, args::ANY...)
970
970
ai = args[i]
971
971
if isType (ai)
972
972
aip1 = ai. parameters[1 ]
973
- canconst &= isleaftype (aip1)
973
+ canconst &= isconcrete (aip1)
974
974
push! (tparams, aip1)
975
975
elseif isa (ai, Const) && (isa (ai. val, Type) || isa (ai. val, TypeVar) || valid_tparam (ai. val))
976
976
push! (tparams, ai. val)
@@ -1045,7 +1045,7 @@ add_tfunc(apply_type, 1, IInf, apply_type_tfunc)
1045
1045
end
1046
1046
1047
1047
function invoke_tfunc (f:: ANY , types:: ANY , argtype:: ANY , sv:: InferenceState )
1048
- if ! isleaftype (Type{types})
1048
+ if ! isconcrete (Type{types})
1049
1049
return Any
1050
1050
end
1051
1051
argtype = typeintersect (types,limit_tuple_type (argtype, sv. params))
@@ -1513,7 +1513,7 @@ function return_type_tfunc(argtypes::ANY, vtypes::VarTable, sv::InferenceState)
1513
1513
if isa (tt, Const) || (isType (tt) && ! has_free_typevars (tt))
1514
1514
aft = argtypes[2 ]
1515
1515
if isa (aft, Const) || (isType (aft) && ! has_free_typevars (aft)) ||
1516
- (isleaftype (aft) && ! (aft <: Builtin ) && ! (aft <: IntrinsicFunction ))
1516
+ (isconcrete (aft) && ! (aft <: Builtin ) && ! (aft <: IntrinsicFunction ))
1517
1517
af_argtype = isa (tt, Const) ? tt. val : tt. parameters[1 ]
1518
1518
if isa (af_argtype, DataType) && af_argtype <: Tuple
1519
1519
argtypes_vec = Any[aft, af_argtype. parameters... ]
@@ -1527,7 +1527,7 @@ function return_type_tfunc(argtypes::ANY, vtypes::VarTable, sv::InferenceState)
1527
1527
if isa (rt, Const)
1528
1528
# output was computed to be constant
1529
1529
return Const (typeof (rt. val))
1530
- elseif isleaftype (rt)
1530
+ elseif isconcrete (rt)
1531
1531
# output type was known for certain
1532
1532
return Const (rt)
1533
1533
elseif (isa (tt, Const) || isconstType (tt)) &&
@@ -1614,9 +1614,9 @@ function abstract_call(f::ANY, fargs::Union{Tuple{},Vector{Any}}, argtypes::Vect
1614
1614
if isa (aft, Const)
1615
1615
af = aft. val
1616
1616
else
1617
- if isType (aft) && isleaftype (aft. parameters[1 ])
1617
+ if isType (aft) && isconcrete (aft. parameters[1 ])
1618
1618
af = aft. parameters[1 ]
1619
- elseif isleaftype (aft) && isdefined (aft, :instance )
1619
+ elseif isconcrete (aft) && isdefined (aft, :instance )
1620
1620
af = aft. instance
1621
1621
else
1622
1622
# TODO jb/functions: take advantage of case where non-constant `af`'s type is known
@@ -1847,9 +1847,9 @@ function abstract_eval_call(e::Expr, vtypes::VarTable, sv::InferenceState)
1847
1847
if isa (ft, Const)
1848
1848
f = ft. val
1849
1849
else
1850
- if isType (ft) && isleaftype (ft. parameters[1 ])
1850
+ if isType (ft) && isconcrete (ft. parameters[1 ])
1851
1851
f = ft. parameters[1 ]
1852
- elseif isleaftype (ft) && isdefined (ft, :instance )
1852
+ elseif isconcrete (ft) && isdefined (ft, :instance )
1853
1853
f = ft. instance
1854
1854
else
1855
1855
for i = 2 : (length (argtypes)- 1 )
@@ -1858,7 +1858,7 @@ function abstract_eval_call(e::Expr, vtypes::VarTable, sv::InferenceState)
1858
1858
end
1859
1859
end
1860
1860
# non-constant function, but type is known
1861
- if (isleaftype (ft) || ft <: Type ) && ! (ft <: Builtin ) && ! (ft <: IntrinsicFunction )
1861
+ if (isconcrete (ft) || ft <: Type ) && ! (ft <: Builtin ) && ! (ft <: IntrinsicFunction )
1862
1862
return abstract_call_gf_by_type (nothing , argtypes_to_type (argtypes), sv)
1863
1863
end
1864
1864
return Any
@@ -2370,7 +2370,7 @@ function code_for_method(method::Method, atypes::ANY, sparams::SimpleVector, wor
2370
2370
if world < min_world (method) || world > max_world (method)
2371
2371
return nothing
2372
2372
end
2373
- if method. isstaged && ! isleaftype (atypes)
2373
+ if method. isstaged && ! isconcrete (atypes)
2374
2374
# don't call staged functions on abstract types.
2375
2375
# (see issues #8504, #10230)
2376
2376
# we can't guarantee that their type behavior is monotonic.
@@ -3397,7 +3397,7 @@ function effect_free(e::ANY, src::CodeInfo, mod::Module, allow_volatile::Bool)
3397
3397
return false
3398
3398
elseif is_known_call (e, getfield, src, mod)
3399
3399
et = exprtype (e, src, mod)
3400
- if ! isa (et,Const) && ! (isType (et) && isleaftype (et))
3400
+ if ! isa (et,Const) && ! (isType (et) && isconcrete (et))
3401
3401
# first argument must be immutable to ensure e is affect_free
3402
3402
a = ea[2 ]
3403
3403
typ = widenconst (exprtype (a, src, mod))
@@ -3635,15 +3635,15 @@ end
3635
3635
3636
3636
# inline functions whose bodies are "inline_worthy"
3637
3637
# where the function body doesn't contain any argument more than once.
3638
- # static parameters are ok if all the static parameter values are leaf types,
3638
+ # static parameters are ok if all the static parameter values are concrete types,
3639
3639
# meaning they are fully known.
3640
3640
# `ft` is the type of the function. `f` is the exact function if known, or else `nothing`.
3641
3641
function inlineable (f:: ANY , ft:: ANY , e:: Expr , atypes:: Vector{Any} , sv:: InferenceState )
3642
3642
argexprs = e. args
3643
3643
3644
3644
if (f === typeassert || ft ⊑ typeof (typeassert)) && length (atypes)== 3
3645
3645
# typeassert(x::S, T) => x, when S<:T
3646
- if isType (atypes[3 ]) && isleaftype (atypes[3 ]) &&
3646
+ if isType (atypes[3 ]) && isconcrete (atypes[3 ]) &&
3647
3647
atypes[2 ] ⊑ atypes[3 ]. parameters[1 ]
3648
3648
return (argexprs[2 ], ())
3649
3649
end
@@ -3667,7 +3667,7 @@ function inlineable(f::ANY, ft::ANY, e::Expr, atypes::Vector{Any}, sv::Inference
3667
3667
if f === Core. invoke && length (atypes) >= 3
3668
3668
ft = widenconst (atypes[2 ])
3669
3669
invoke_tt = widenconst (atypes[3 ])
3670
- if ! isleaftype (ft) || ! isleaftype (invoke_tt) || ! isType (invoke_tt)
3670
+ if ! isconcrete (ft) || ! isconcrete (invoke_tt) || ! isType (invoke_tt)
3671
3671
return NF
3672
3672
end
3673
3673
if ! (isa (invoke_tt. parameters[1 ], Type) &&
@@ -4333,7 +4333,7 @@ function inlining_pass(e::Expr, sv::InferenceState)
4333
4333
ft = Bool
4334
4334
else
4335
4335
f = nothing
4336
- if ! ( isleaftype (ft) || ft<: Type )
4336
+ if ! ( isconcrete (ft) || ft<: Type )
4337
4337
return (e, stmts)
4338
4338
end
4339
4339
end
@@ -4438,7 +4438,7 @@ function inlining_pass(e::Expr, sv::InferenceState)
4438
4438
ft = Bool
4439
4439
else
4440
4440
f = nothing
4441
- if ! ( isleaftype (ft) || ft<: Type )
4441
+ if ! ( isconcrete (ft) || ft<: Type )
4442
4442
return (e,stmts)
4443
4443
end
4444
4444
end
@@ -4950,7 +4950,7 @@ function is_allocation(e::ANY, sv::InferenceState)
4950
4950
return (length (e. args)- 1 ,())
4951
4951
elseif e. head === :new
4952
4952
typ = widenconst (exprtype (e, sv. src, sv. mod))
4953
- if isa (typ, DataType) && isleaftype (typ)
4953
+ if isa (typ, DataType) && isconcrete (typ)
4954
4954
nf = length (e. args) - 1
4955
4955
names = fieldnames (typ)
4956
4956
@assert (nf <= nfields (typ))
0 commit comments