+ /**
+ * Routing of the request to build an effective statement from {@link InferredStatementContext} towards the original
+ * definition site. This is needed to pick the correct instantiation method: for declared statements we will
+ * eventually land in {@link AbstractResumedStatement}, for underclared statements that will be
+ * {@link UndeclaredStmtCtx}.
+ *
+ * @param factory Statement factory
+ * @param ctx Inferred statement context, i.e. where the effective statement is instantiated
+ * @return Built effective stateue
+ */
+ abstract @NonNull E createInferredEffective(@NonNull StatementFactory<A, D, E> factory,
+ @NonNull InferredStatementContext<A, D, E> ctx, Stream<? extends StmtContext<?, ?, ?>> declared,
+ Stream<? extends StmtContext<?, ?, ?>> effective);
+
+ /**
+ * Attach an effective copy of this statement. This essentially acts as a map, where we make a few assumptions:
+ * <ul>
+ * <li>{@code copy} and {@code this} statement share {@link #getOriginalCtx()} if it exists</li>
+ * <li>{@code copy} did not modify any statements relative to {@code this}</li>
+ * </ul>
+ *
+ * @param state effective statement state, acting as a lookup key
+ * @param stmt New copy to append
+ * @return {@code stmt} or a previously-created instances with the same {@code state}
+ */
+ @SuppressWarnings("unchecked")
+ final @NonNull E attachEffectiveCopy(final @NonNull EffectiveStatementState state, final @NonNull E stmt) {
+ final Object local = effectiveInstance;
+ final EffectiveInstances<E> instances;
+ if (local instanceof EffectiveInstances) {
+ instances = (EffectiveInstances<E>) local;
+ } else {
+ effectiveInstance = instances = new EffectiveInstances<>((E) local);
+ }
+ return instances.attachCopy(state, stmt);
+ }
+