@@ -543,25 +543,30 @@ function abstract_call_method(interp::AbstractInterpreter,
543543 if topmost != = nothing
544544 msig = unwrap_unionall (method. sig):: DataType
545545 spec_len = length (msig. parameters) + 1
546- ls = length (sigtuple. parameters)
547546 mi = frame_instance (sv)
548547
548+ if isdefined (method, :recursion_relation )
549+ # We don't require the recursion_relation to be transitive, so
550+ # apply a hard limit
551+ hardlimit = true
552+ end
553+
549554 if method === mi. def
550555 # Under direct self-recursion, permit much greater use of reducers.
551556 # here we assume that complexity(specTypes) :>= complexity(sig)
552557 comparison = mi. specTypes
553558 l_comparison = length ((unwrap_unionall (comparison):: DataType ). parameters)
554559 spec_len = max (spec_len, l_comparison)
560+ elseif ! hardlimit && isa (topmost, InferenceState)
561+ # Without a hardlimit, permit use of reducers too.
562+ comparison = frame_instance (topmost). specTypes
563+ # n.b. currently don't allow vararg reducers
564+ # l_comparison = length((unwrap_unionall(comparison)::DataType).parameters)
565+ # spec_len = max(spec_len, l_comparison)
555566 else
556567 comparison = method. sig
557568 end
558569
559- if isdefined (method, :recursion_relation )
560- # We don't require the recursion_relation to be transitive, so
561- # apply a hard limit
562- hardlimit = true
563- end
564-
565570 # see if the type is actually too big (relative to the caller), and limit it if required
566571 newsig = limit_type_size (sig, comparison, hardlimit ? comparison : mi. specTypes, InferenceParams (interp). tuple_complexity_limit_depth, spec_len)
567572
@@ -588,6 +593,7 @@ function abstract_call_method(interp::AbstractInterpreter,
588593 poison_callstack! (sv, parentframe === nothing ? topmost : parentframe)
589594 end
590595 end
596+ # n.b. this heuristic depends on the non-local state, so we must record the limit later
591597 sig = newsig
592598 sparams = svec ()
593599 edgelimited = true
0 commit comments