@@ -1911,7 +1911,20 @@ end
1911
1911
1912
1912
function method_for_inference_heuristics (infstate:: InferenceState )
1913
1913
m = infstate. src. method_for_inference_heuristics
1914
- return m === nothing ? infstate. linfo. def : m
1914
+ return isa (m, Method) ? m : infstate. linfo. def
1915
+ end
1916
+
1917
+ function method_for_inference_heuristics (method:: Method , @nospecialize (sig), sparams, world)
1918
+ if isdefined (method, :generator ) && method. generator. expand_early
1919
+ method_instance = code_for_method (method, sig, sparams, world, false )
1920
+ if isa (method_instance, MethodInstance)
1921
+ cinfo = get_staged (method_instance)
1922
+ if isa (cinfo, CodeInfo) && isa (cinfo. method_for_inference_heuristics, Method)
1923
+ return cinfo. method_for_inference_heuristics
1924
+ end
1925
+ end
1926
+ end
1927
+ return method
1915
1928
end
1916
1929
1917
1930
function abstract_call_method (method:: Method , @nospecialize (f), @nospecialize (sig), sparams:: SimpleVector , sv:: InferenceState )
@@ -1922,17 +1935,7 @@ function abstract_call_method(method::Method, @nospecialize(f), @nospecialize(si
1922
1935
# Returns the topmost occurrence of that repeated edge.
1923
1936
cyclei = 0
1924
1937
infstate = sv
1925
- if isdefined (method, :generator ) # && method.generator.expand_early
1926
- method_instance = code_for_method (method, sig, sparams, sv. params. world, false )
1927
- if isa (method_instance, MethodInstance)
1928
- cinfo = get_staged (method_instance)
1929
- if isa (cinfo, CodeInfo) && isa (cinfo. method_for_inference_heuristics, Method)
1930
- checked_method = cinfo. method_for_inference_heuristics
1931
- end
1932
- end
1933
- else
1934
- checked_method = method
1935
- end
1938
+ checked_method = method_for_inference_heuristics (method, sig, sparams, sv. params. world)
1936
1939
while ! (infstate === nothing )
1937
1940
infstate = infstate:: InferenceState
1938
1941
if method === infstate. linfo. def && infstate. linfo. specTypes == sig
0 commit comments