@@ -16,7 +16,8 @@ const _REF_NAME = Ref.body.name
1616call_result_unused (frame:: InferenceState , pc:: LineNum = frame. currpc) = 
1717    isexpr (frame. src. code[frame. currpc], :call ) &&  isempty (frame. ssavalue_uses[pc])
1818
19- function  abstract_call_gf_by_type (@nospecialize (f), argtypes:: Vector{Any} , @nospecialize (atype), sv:: InferenceState )
19+ function  abstract_call_gf_by_type (@nospecialize (f), argtypes:: Vector{Any} , @nospecialize (atype), sv:: InferenceState ,
20+                                   max_methods =  sv. params. MAX_METHODS)
2021    atype_params =  unwrap_unionall (atype). parameters
2122    ft =  unwrap_unionall (atype_params[1 ]) #  TODO : ccall jl_first_argument_datatype here
2223    isa (ft, DataType) ||  return  Any #  the function being called is unknown. can't properly handle this backedge right now
@@ -41,12 +42,12 @@ function abstract_call_gf_by_type(@nospecialize(f), argtypes::Vector{Any}, @nosp
4142        splitsigs =  switchtupleunion (atype)
4243        applicable =  Any[]
4344        for  sig_n in  splitsigs
44-             xapplicable =  _methods_by_ftype (sig_n, sv . params . MAX_METHODS , sv. params. world, min_valid, max_valid)
45+             xapplicable =  _methods_by_ftype (sig_n, max_methods , sv. params. world, min_valid, max_valid)
4546            xapplicable ===  false  &&  return  Any
4647            append! (applicable, xapplicable)
4748        end 
4849    else 
49-         applicable =  _methods_by_ftype (atype, sv . params . MAX_METHODS , sv. params. world, min_valid, max_valid)
50+         applicable =  _methods_by_ftype (atype, max_methods , sv. params. world, min_valid, max_valid)
5051        if  applicable ===  false 
5152            #  this means too many methods matched
5253            #  (assume this will always be true, so we don't compute / update valid age in this case)
@@ -489,7 +490,8 @@ function abstract_iteration(@nospecialize(itertype), vtypes::VarTable, sv::Infer
489490end 
490491
491492#  do apply(af, fargs...), where af is a function value
492- function  abstract_apply (@nospecialize (aft), aargtypes:: Vector{Any} , vtypes:: VarTable , sv:: InferenceState )
493+ function  abstract_apply (@nospecialize (aft), aargtypes:: Vector{Any} , vtypes:: VarTable , sv:: InferenceState ,
494+                         max_methods =  sv. params. MAX_METHODS)
493495    if  ! isa (aft, Const) &&  (! isType (aft) ||  has_free_typevars (aft))
494496        if  ! isconcretetype (aft) ||  (aft <:  Builtin )
495497            #  non-constant function of unknown type: bail now,
@@ -522,12 +524,12 @@ function abstract_apply(@nospecialize(aft), aargtypes::Vector{Any}, vtypes::VarT
522524    end 
523525    for  ct in  ctypes
524526        if  isa (aft, Const)
525-             rt =  abstract_call (aft. val, (), ct, vtypes, sv)
527+             rt =  abstract_call (aft. val, (), ct, vtypes, sv, max_methods )
526528        elseif  isconstType (aft)
527-             rt =  abstract_call (aft. parameters[1 ], (), ct, vtypes, sv)
529+             rt =  abstract_call (aft. parameters[1 ], (), ct, vtypes, sv, max_methods )
528530        else 
529531            astype =  argtypes_to_type (ct)
530-             rt =  abstract_call_gf_by_type (nothing , ct, astype, sv)
532+             rt =  abstract_call_gf_by_type (nothing , ct, astype, sv, max_methods )
531533        end 
532534        res =  tmerge (res, rt)
533535        if  res ===  Any
@@ -568,9 +570,9 @@ function pure_eval_call(@nospecialize(f), argtypes::Vector{Any}, @nospecialize(a
568570    end 
569571end 
570572
571- function  abstract_call (@nospecialize (f), fargs:: Union{Tuple{},Vector{Any}} , argtypes:: Vector{Any} , vtypes:: VarTable , sv:: InferenceState )
573+ function  abstract_call (@nospecialize (f), fargs:: Union{Tuple{},Vector{Any}} , argtypes:: Vector{Any} , vtypes:: VarTable , sv:: InferenceState , max_methods  =  sv . params . MAX_METHODS )
572574    if  f ===  _apply
573-         return  abstract_apply (argtypes[2 ], argtypes[3 : end ], vtypes, sv)
575+         return  abstract_apply (argtypes[2 ], argtypes[3 : end ], vtypes, sv, max_methods )
574576    end 
575577
576578    la =  length (argtypes)
@@ -779,7 +781,7 @@ function abstract_call(@nospecialize(f), fargs::Union{Tuple{},Vector{Any}}, argt
779781        return  Type #  don't try to infer these function edges directly -- it won't actually come up with anything useful
780782    end 
781783
782-     return  abstract_call_gf_by_type (f, argtypes, atype, sv)
784+     return  abstract_call_gf_by_type (f, argtypes, atype, sv, max_methods )
783785end 
784786
785787#  wrapper around `abstract_call` for first computing if `f` is available
0 commit comments