@@ -305,7 +305,12 @@ function InferenceState(linfo::MethodInstance,
305
305
end
306
306
307
307
function get_staged (li:: MethodInstance )
308
- return ccall (:jl_code_for_staged , Any, (Any,), li):: CodeInfo
308
+ try
309
+ # user code might throw errors – ignore them
310
+ return ccall (:jl_code_for_staged , Any, (Any,), li):: CodeInfo
311
+ catch
312
+ return nothing
313
+ end
309
314
end
310
315
311
316
405
410
function retrieve_code_info (linfo:: MethodInstance )
406
411
m = linfo. def:: Method
407
412
if isdefined (m, :generator )
408
- try
409
- # user code might throw errors – ignore them
410
- c = get_staged (linfo)
411
- catch
412
- return nothing
413
- end
413
+ return get_staged (linfo)
414
414
else
415
415
# TODO : post-inference see if we can swap back to the original arrays?
416
416
if isa (m. source, Array{UInt8,1 })
@@ -1922,6 +1922,17 @@ function abstract_call_method(method::Method, @nospecialize(f), @nospecialize(si
1922
1922
# Returns the topmost occurrence of that repeated edge.
1923
1923
cyclei = 0
1924
1924
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
1925
1936
while ! (infstate === nothing )
1926
1937
infstate = infstate:: InferenceState
1927
1938
if method === infstate. linfo. def && infstate. linfo. specTypes == sig
@@ -1931,7 +1942,7 @@ function abstract_call_method(method::Method, @nospecialize(f), @nospecialize(si
1931
1942
break
1932
1943
end
1933
1944
working_method = method_for_inference_heuristics (infstate)
1934
- if method === working_method
1945
+ if checked_method === working_method
1935
1946
if topmost === nothing
1936
1947
# inspect the parent of this edge,
1937
1948
# to see if they are the same Method as sv
0 commit comments