@@ -1909,6 +1909,11 @@ function abstract_call_gf_by_type(@nospecialize(f), @nospecialize(atype), sv::In
1909
1909
return rettype
1910
1910
end
1911
1911
1912
+ function method_for_inference_heuristics (infstate:: InferenceState )
1913
+ m = infstate. src. method_for_inference_heuristics
1914
+ return m === nothing ? infstate. linfo. def : m
1915
+ end
1916
+
1912
1917
function abstract_call_method (method:: Method , @nospecialize (f), @nospecialize (sig), sparams:: SimpleVector , sv:: InferenceState )
1913
1918
topmost = nothing
1914
1919
# Limit argument type tuple growth of functions:
@@ -1919,13 +1924,14 @@ function abstract_call_method(method::Method, @nospecialize(f), @nospecialize(si
1919
1924
infstate = sv
1920
1925
while ! (infstate === nothing )
1921
1926
infstate = infstate:: InferenceState
1922
- if method === infstate. linfo. def
1923
- if infstate. linfo. specTypes == sig
1924
- # avoid widening when detecting self-recursion
1925
- # TODO : merge call cycle and return right away
1926
- topmost = nothing
1927
- break
1928
- end
1927
+ if method === infstate. linfo. def && infstate. linfo. specTypes == sig
1928
+ # avoid widening when detecting self-recursion
1929
+ # TODO : merge call cycle and return right away
1930
+ topmost = nothing
1931
+ break
1932
+ end
1933
+ working_method = method_for_inference_heuristics (infstate)
1934
+ if method === working_method
1929
1935
if topmost === nothing
1930
1936
# inspect the parent of this edge,
1931
1937
# to see if they are the same Method as sv
@@ -1943,7 +1949,8 @@ function abstract_call_method(method::Method, @nospecialize(f), @nospecialize(si
1943
1949
# then check the parent link
1944
1950
if topmost === nothing && parent != = nothing
1945
1951
parent = parent:: InferenceState
1946
- if parent. cached && parent. linfo. def === sv. linfo. def
1952
+ parent_method = method_for_inference_heuristics (parent)
1953
+ if parent. cached && parent_method === working_method
1947
1954
topmost = infstate
1948
1955
end
1949
1956
end
@@ -3220,6 +3227,7 @@ function typeinf_code(linfo::MethodInstance, optimize::Bool, cached::Bool,
3220
3227
tree. slotflags = UInt8[ 0 for i = 1 : method. nargs ]
3221
3228
tree. slottypes = nothing
3222
3229
tree. ssavaluetypes = 0
3230
+ tree. method_for_inference_heuristics = nothing
3223
3231
tree. inferred = true
3224
3232
tree. pure = true
3225
3233
tree. inlineable = true
0 commit comments