@@ -75,7 +75,12 @@ def prepare_definition_ids
7575 runtime_name = if definition . respond_to? ( :runtime_function_definition )
7676 definition . runtime_function_definition &.runtime_name
7777 end
78+ definition_source = definition . runtime_function_definition &.definition_source
7879 function_definitions_by_runtime_id [ runtime_name ] ||= definition if runtime_name . present?
80+ if definition_source . present?
81+ function_definitions_by_runtime_id [ [ definition . identifier , definition_source ] ] ||= definition
82+ function_definitions_by_runtime_id [ [ runtime_name , definition_source ] ] ||= definition if runtime_name . present?
83+ end
7984 end
8085 end
8186
@@ -176,11 +181,15 @@ def reference_path_to_h(path)
176181 end
177182
178183 def sub_flow_to_h ( sub_flow )
179- function_definition = function_definition_for_identifier ( sub_flow . function_identifier )
180- if runtime . present? && sub_flow . function_identifier . present? && function_definition . nil?
184+ sub_flow_function = sub_flow . function if sub_flow . execution_reference == :function
185+ function_identifier = sub_flow_function &.function_identifier
186+ definition_source = sub_flow_function . definition_source if sub_flow_function &.has_definition_source?
187+ function_definition = function_definition_for_identifier ( function_identifier , definition_source )
188+ if runtime . present? && function_identifier . present? && function_definition . nil?
181189 raise_unresolved_definition (
182190 'Generated sub-flow function definition is unknown' ,
183- function_identifier : sub_flow . function_identifier
191+ function_identifier : function_identifier ,
192+ definition_source : definition_source
184193 )
185194 end
186195
@@ -251,7 +260,11 @@ def function_definition_for(node)
251260 function_definition_for_identifier ( node . runtime_function_id )
252261 end
253262
254- def function_definition_for_identifier ( identifier )
263+ def function_definition_for_identifier ( identifier , definition_source = nil )
264+ return if identifier . blank?
265+
266+ return function_definitions_by_runtime_id [ [ identifier , definition_source ] ] if definition_source . present?
267+
255268 function_definitions_by_runtime_id [ identifier ]
256269 end
257270
0 commit comments