@@ -219,6 +219,11 @@ cmp_tfunc = (x,y)->Bool
219219
220220isType (t:: ANY ) = isa (t,DataType) && is ((t:: DataType ). name,Type. name)
221221
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+
222227const IInf = typemax (Int) # integer infinity
223228const n_ifunc = reinterpret (Int32,arraylen)+ 1
224229const t_ifunc = Array {Tuple{Int,Int,Any},1} (n_ifunc)
967972
968973function pure_eval_call (f:: ANY , argtypes:: ANY , atype, vtypes, sv)
969974 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 ))
971976 return false
972977 end
973978 end
@@ -1960,7 +1965,7 @@ function finish(me::InferenceState)
19601965 # need to add coverage support to the `jl_call_method_internal` fast path
19611966 if ! do_coverage &&
19621967 ((isa (me. bestguess,Const) && me. bestguess. val != = nothing ) ||
1963- ( isType ( me. bestguess) && ! has_typevars (me . bestguess . parameters[ 1 ] ,true ) ))
1968+ isconstType ( me. bestguess,true ))
19641969 if ! ispure && length (me. linfo. code) < 10
19651970 ispure = true
19661971 for stmt in me. linfo. code
@@ -2382,7 +2387,7 @@ function inlineable(f::ANY, ft::ANY, e::Expr, atypes::Vector{Any}, sv::Inference
23822387 topmod = _topmod (sv)
23832388 # special-case inliners for known pure functions that compute types
23842389 if sv. inlining
2385- if isType (e. typ) && ! has_typevars (e . typ . parameters[ 1 ] ,true )
2390+ if isconstType (e. typ,true )
23862391 if (is (f, apply_type) || is (f, fieldtype) || is (f, typeof) ||
23872392 istopfunction (topmod, f, :typejoin ) ||
23882393 istopfunction (topmod, f, :promote_type ))
@@ -2533,14 +2538,10 @@ function inlineable(f::ANY, ft::ANY, e::Expr, atypes::Vector{Any}, sv::Inference
25332538 methsp = meth[2 ]
25342539 method = meth[3 ]:: Method
25352540 # 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)
25442545 return inline_as_constant (e. typ. val, argexprs, enclosing)
25452546 end
25462547 end
0 commit comments