@@ -549,25 +549,30 @@ function abstract_call_method(interp::AbstractInterpreter,
549
549
if topmost != = nothing
550
550
msig = unwrap_unionall (method. sig):: DataType
551
551
spec_len = length (msig. parameters) + 1
552
- ls = length (sigtuple. parameters)
553
552
mi = frame_instance (sv)
554
553
554
+ if isdefined (method, :recursion_relation )
555
+ # We don't require the recursion_relation to be transitive, so
556
+ # apply a hard limit
557
+ hardlimit = true
558
+ end
559
+
555
560
if method === mi. def
556
561
# Under direct self-recursion, permit much greater use of reducers.
557
562
# here we assume that complexity(specTypes) :>= complexity(sig)
558
563
comparison = mi. specTypes
559
564
l_comparison = length ((unwrap_unionall (comparison):: DataType ). parameters)
560
565
spec_len = max (spec_len, l_comparison)
566
+ elseif ! hardlimit && isa (topmost, InferenceState)
567
+ # Without a hardlimit, permit use of reducers too.
568
+ comparison = frame_instance (topmost). specTypes
569
+ # n.b. currently don't allow vararg reducers
570
+ # l_comparison = length((unwrap_unionall(comparison)::DataType).parameters)
571
+ # spec_len = max(spec_len, l_comparison)
561
572
else
562
573
comparison = method. sig
563
574
end
564
575
565
- if isdefined (method, :recursion_relation )
566
- # We don't require the recursion_relation to be transitive, so
567
- # apply a hard limit
568
- hardlimit = true
569
- end
570
-
571
576
# see if the type is actually too big (relative to the caller), and limit it if required
572
577
newsig = limit_type_size (sig, comparison, hardlimit ? comparison : mi. specTypes, InferenceParams (interp). tuple_complexity_limit_depth, spec_len)
573
578
@@ -594,6 +599,7 @@ function abstract_call_method(interp::AbstractInterpreter,
594
599
poison_callstack! (sv, parentframe === nothing ? topmost : parentframe)
595
600
end
596
601
end
602
+ # n.b. this heuristic depends on the non-local state, so we must record the limit later
597
603
sig = newsig
598
604
sparams = svec ()
599
605
edgelimited = true
0 commit comments