@@ -543,25 +543,30 @@ function abstract_call_method(interp::AbstractInterpreter,
543
543
if topmost != = nothing
544
544
msig = unwrap_unionall (method. sig):: DataType
545
545
spec_len = length (msig. parameters) + 1
546
- ls = length (sigtuple. parameters)
547
546
mi = frame_instance (sv)
548
547
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
+
549
554
if method === mi. def
550
555
# Under direct self-recursion, permit much greater use of reducers.
551
556
# here we assume that complexity(specTypes) :>= complexity(sig)
552
557
comparison = mi. specTypes
553
558
l_comparison = length ((unwrap_unionall (comparison):: DataType ). parameters)
554
559
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)
555
566
else
556
567
comparison = method. sig
557
568
end
558
569
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
-
565
570
# see if the type is actually too big (relative to the caller), and limit it if required
566
571
newsig = limit_type_size (sig, comparison, hardlimit ? comparison : mi. specTypes, InferenceParams (interp). tuple_complexity_limit_depth, spec_len)
567
572
@@ -588,6 +593,7 @@ function abstract_call_method(interp::AbstractInterpreter,
588
593
poison_callstack! (sv, parentframe === nothing ? topmost : parentframe)
589
594
end
590
595
end
596
+ # n.b. this heuristic depends on the non-local state, so we must record the limit later
591
597
sig = newsig
592
598
sparams = svec ()
593
599
edgelimited = true
0 commit comments