Refactor type intersection path processing to its own function
@@ -739,19 +739,14 @@ def process_set_as_link_property_ref(
return SetRVars(main=SetRVar(link_rvar, ir_set.path_id), new=rvars)
-def process_set_as_path(
- ir_set: irast.Set, stmt: pgast.SelectStmt, *,
+def process_set_as_path_type_intersection(
+ ir_set: irast.Set, stmt: pgast.SelectStmt,
+ ptrref: irast.TypeIntersectionPointerRef,
+ source_is_visible: bool,
+ *,
ctx: context.CompilerContextLevel) -> SetRVars:
- rptr = ir_set.rptr
- ptrref = rptr.ptrref
- ir_source = rptr.source
- source_is_visible = ctx.scope_tree.is_visible(ir_source.path_id)
- is_type_intersection = ir_set.path_id.is_type_intersection_path()
-
- rvars = []
+ ir_source = ir_set.rptr.source
- if is_type_intersection:
- ptrref = cast(irast.TypeIntersectionPointerRef, ptrref)
if (not source_is_visible
and ir_source.rptr is not None
and not ir_source.path_id.is_type_intersection_path()
@@ -844,6 +839,24 @@ def process_set_as_path(
return new_stmt_set_rvar(
ir_set, stmt, aspects=['value', 'source'], ctx=ctx)
+
+def process_set_as_path(
+ ir_set: irast.Set, stmt: pgast.SelectStmt, *,
+ ctx: context.CompilerContextLevel) -> SetRVars:
+ rptr = ir_set.rptr
+ ptrref = rptr.ptrref
+ ir_source = rptr.source
+ source_is_visible = ctx.scope_tree.is_visible(ir_source.path_id)
+
+ rvars = []
+
+ # Type intersection paths have their own entire code path.
+ if ir_set.path_id.is_type_intersection_path():
+ ptrref = cast(irast.TypeIntersectionPointerRef, ptrref)
+ return process_set_as_path_type_intersection(
+ ir_set, stmt, ptrref, source_is_visible,
+ ctx=ctx)
+
ptr_info = pg_types.get_ptrref_storage_info(
ptrref, resolve_type=False, link_bias=False)
