Skip to content

Commit 09f5946

Browse files
authored
follow up the fix for #418 (#422)
1 parent 0be0728 commit 09f5946

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/interpreter.jl

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,13 +135,28 @@ function CC.type_annotate!(interp::CthulhuInterpreter, sv::InferenceState, run_o
135135
end
136136
end
137137

138+
function annotate_slottypes!(sv::InferenceState)
139+
slottypes = sv.slottypes
140+
for i = 1:length(slottypes)
141+
slottypes[i] = CC.widenconditional(slottypes[i])
142+
end
143+
CC.record_slot_assign!(sv)
144+
return sv.src.slottypes
145+
end
146+
138147
function CC.finish(state::InferenceState, interp::CthulhuInterpreter)
139148
res = @invoke CC.finish(state::InferenceState, interp::AbstractInterpreter)
140149
key = CC.any(state.result.overridden_by_const) ? state.result : state.linfo
141150
unoptsrc = copy(state.src)
142151
unoptsrc.slotnames = copy(unoptsrc.slotnames)
143152
unoptsrc.slottypes = let slottypes = unoptsrc.slottypes
144-
slottypes === nothing ? nothing : copy(unoptsrc.slottypes)
153+
# TODO this is only supported in 1.9 and higher
154+
# if slottypes === nothing
155+
# # `slottypes::Vector{Any}` hasn't been generated due to recursion,
156+
# # so manually generate it here
157+
# slottypes = annotate_slottypes!(state)
158+
# end
159+
slottypes === nothing ? nothing : copy(slottypes)
145160
end
146161
unoptsrc.slotflags = copy(unoptsrc.slotflags)
147162
interp.unopt[key] = InferredSource(

0 commit comments

Comments
 (0)