@@ -219,6 +219,11 @@ cmp_tfunc = (x,y)->Bool
219
219
220
220
isType (t:: ANY ) = isa (t,DataType) && is ((t:: DataType ). name,Type. name)
221
221
222
+ # true if Type is inlineable as constant
223
+ isconstType (t:: ANY ,b:: Bool ) =
224
+ isType (t) && ! has_typevars (t. parameters[1 ],b) &&
225
+ ! issubtype (Tuple{Vararg}, t. parameters[1 ]) # work around inference bug #18450
226
+
222
227
const IInf = typemax (Int) # integer infinity
223
228
const n_ifunc = reinterpret (Int32,arraylen)+ 1
224
229
const t_ifunc = Array {Tuple{Int,Int,Any},1} (n_ifunc)
967
972
968
973
function pure_eval_call (f:: ANY , argtypes:: ANY , atype, vtypes, sv)
969
974
for a in drop (argtypes,1 )
970
- if ! (isa (a,Const) || ( isType (a) && ! has_typevars (a . parameters[ 1 ]) ))
975
+ if ! (isa (a,Const) || isconstType (a, false ))
971
976
return false
972
977
end
973
978
end
@@ -1960,7 +1965,7 @@ function finish(me::InferenceState)
1960
1965
# need to add coverage support to the `jl_call_method_internal` fast path
1961
1966
if ! do_coverage &&
1962
1967
((isa (me. bestguess,Const) && me. bestguess. val != = nothing ) ||
1963
- ( isType ( me. bestguess) && ! has_typevars (me . bestguess . parameters[ 1 ] ,true ) ))
1968
+ isconstType ( me. bestguess,true ))
1964
1969
if ! ispure && length (me. linfo. code) < 10
1965
1970
ispure = true
1966
1971
for stmt in me. linfo. code
@@ -2382,7 +2387,7 @@ function inlineable(f::ANY, ft::ANY, e::Expr, atypes::Vector{Any}, sv::Inference
2382
2387
topmod = _topmod (sv)
2383
2388
# special-case inliners for known pure functions that compute types
2384
2389
if sv. inlining
2385
- if isType (e. typ) && ! has_typevars (e . typ . parameters[ 1 ] ,true )
2390
+ if isconstType (e. typ,true )
2386
2391
if (is (f, apply_type) || is (f, fieldtype) || is (f, typeof) ||
2387
2392
istopfunction (topmod, f, :typejoin ) ||
2388
2393
istopfunction (topmod, f, :promote_type ))
@@ -2533,14 +2538,10 @@ function inlineable(f::ANY, ft::ANY, e::Expr, atypes::Vector{Any}, sv::Inference
2533
2538
methsp = meth[2 ]
2534
2539
method = meth[3 ]:: Method
2535
2540
# check whether call can be inlined to just a quoted constant value
2536
- if isa (f, widenconst (ft)) && ! method. isstaged && (method. lambda_template. pure || f === return_type) &&
2537
- (isType (e. typ) || isa (e. typ,Const))
2538
- if isType (e. typ)
2539
- if ! has_typevars (e. typ. parameters[1 ])
2540
- return inline_as_constant (e. typ. parameters[1 ], argexprs, enclosing)
2541
- end
2542
- else
2543
- assert (isa (e. typ,Const))
2541
+ if isa (f, widenconst (ft)) && ! method. isstaged && (method. lambda_template. pure || f === return_type)
2542
+ if isconstType (e. typ,false )
2543
+ return inline_as_constant (e. typ. parameters[1 ], argexprs, enclosing)
2544
+ elseif isa (e. typ,Const)
2544
2545
return inline_as_constant (e. typ. val, argexprs, enclosing)
2545
2546
end
2546
2547
end
0 commit comments