@@ -17,6 +17,8 @@ type InferenceParams
17
17
MAX_TUPLE_SPLAT:: Int
18
18
MAX_UNION_SPLITTING:: Int
19
19
20
+ # default values will be used for regular compilation, as the compiler calls typeinf_ext
21
+ # without specifying, or allowing to override, the inference parameters
20
22
InferenceParams (;optimize:: Bool = true , inlining:: Bool = inlining_enabled (), needtree:: Bool = true ,
21
23
typeunion_len= 3 :: Int , type_depth= 7 :: Int , tupletype_len= 15 :: Int ,
22
24
tuple_depth= 16 :: Int , tuple_splat= 4 :: Int , union_splitting= 4 :: Int ) =
@@ -1620,9 +1622,9 @@ function typeinf_edge(method::Method, atypes::ANY, sparams::SimpleVector, caller
1620
1622
return typeinf_edge (method, atypes, sparams, true , caller,
1621
1623
InferenceParams (needtree= false ), InferenceHooks ())
1622
1624
end
1623
- function typeinf (method:: Method , atypes:: ANY , sparams:: SimpleVector , needtree :: Bool = false )
1624
- return typeinf_edge (method, atypes, sparams, true , nothing ,
1625
- InferenceParams (needtree = needtree) , InferenceHooks ())
1625
+ function typeinf (method:: Method , atypes:: ANY , sparams:: SimpleVector ,
1626
+ params :: InferenceParams = InferenceParams ())
1627
+ return typeinf_edge (method, atypes, sparams, true , nothing , params , InferenceHooks ())
1626
1628
end
1627
1629
# compute an inferred (optionally optimized) AST without global effects (i.e. updating the cache)
1628
1630
# TODO : make this use a custom cache, which we then can either keep around or throw away
@@ -2593,7 +2595,7 @@ function inlineable(f::ANY, ft::ANY, e::Expr, atypes::Vector{Any}, sv::Inference
2593
2595
isa (si, TypeVar) && return NF
2594
2596
end
2595
2597
2596
- (linfo, ty, inferred) = typeinf (method, metharg, methsp, false )
2598
+ (linfo, ty, inferred) = typeinf (method, metharg, methsp, InferenceParams (needtree = false ) )
2597
2599
if linfo === nothing || ! inferred
2598
2600
return invoke_NF ()
2599
2601
end
@@ -2603,7 +2605,7 @@ function inlineable(f::ANY, ft::ANY, e::Expr, atypes::Vector{Any}, sv::Inference
2603
2605
elseif linfo != = nothing && ! linfo. inlineable
2604
2606
return invoke_NF ()
2605
2607
elseif linfo === nothing || linfo. code === nothing
2606
- (linfo, ty, inferred) = typeinf (method, metharg, methsp, true )
2608
+ (linfo, ty, inferred) = typeinf (method, metharg, methsp)
2607
2609
end
2608
2610
if linfo === nothing || ! inferred || ! linfo. inlineable || (ast = linfo. code) === nothing
2609
2611
return invoke_NF ()
@@ -3873,11 +3875,12 @@ function reindex_labels!(linfo::LambdaInfo, sv::InferenceState)
3873
3875
end
3874
3876
3875
3877
function return_type (f:: ANY , t:: ANY , params:: InferenceParams = InferenceParams ())
3876
- # TODO : is this correct? when is return_type actually executed, ie. not pure_eval_call'd?
3877
- # also, should pass params to typeinf
3878
+ # TODO : are all local calls to return_type processed by pure_eval_call?
3879
+ # if not, this behavior isn't correct, as it uses the default params
3880
+ # for a call which might have been inferred with a different set of params
3878
3881
rt = Union{}
3879
3882
for m in _methods (f, t, - 1 )
3880
- _, ty, inferred = typeinf (m[3 ], m[1 ], m[2 ], false )
3883
+ _, ty, inferred = typeinf (m[3 ], m[1 ], m[2 ], InferenceParams (needtree = false ) )
3881
3884
! inferred && return Any
3882
3885
rt = tmerge (rt, ty, params)
3883
3886
rt === Any && break
@@ -3891,8 +3894,8 @@ end
3891
3894
# this ensures that typeinf_ext doesn't recurse before it can add the item to the workq
3892
3895
3893
3896
for m in _methods_by_ftype (Tuple{typeof (typeinf_loop), Vararg{Any}}, 10 )
3894
- typeinf (m[3 ], m[1 ], m[2 ], true )
3897
+ typeinf (m[3 ], m[1 ], m[2 ])
3895
3898
end
3896
3899
for m in _methods_by_ftype (Tuple{typeof (typeinf_edge), Vararg{Any}}, 10 )
3897
- typeinf (m[3 ], m[1 ], m[2 ], true )
3900
+ typeinf (m[3 ], m[1 ], m[2 ])
3898
3901
end
0 commit comments