@Override
public final <X, Y extends DeclaredStatement<X>, Z extends EffectiveStatement<X, Y>>
- Mutable<X, Y, Z> addUndeclaredSubstatement(final StatementSupport<X, Y, Z> support, final X arg) {
+ Mutable<X, Y, Z> createUndeclaredSubstatement(final StatementSupport<X, Y, Z> support, final X arg) {
requireNonNull(support);
checkArgument(support instanceof UndeclaredStatementFactory, "Unsupported statement support %s", support);
final var ret = new UndeclaredStmtCtx<>(this, support, arg);
support.onStatementAdded(ret);
- addEffectiveSubstatement(ret);
return ret;
}
return resized;
}
+ static final void afterAddEffectiveSubstatement(final Mutable<?, ?, ?> substatement) {
+ // Undeclared statements still need to have 'onDeclarationFinished()' triggered
+ if (substatement instanceof UndeclaredStmtCtx) {
+ finishDeclaration((UndeclaredStmtCtx<?, ?, ?>) substatement);
+ }
+ }
+
+ // Split out to keep generics working without a warning
+ private static <X, Y extends DeclaredStatement<X>, Z extends EffectiveStatement<X, Y>> void finishDeclaration(
+ final UndeclaredStmtCtx<X, Y, Z> substatement) {
+ substatement.definition().onDeclarationFinished(substatement, ModelProcessingPhase.FULL_DECLARATION);
+ }
+
@Override
public final void addEffectiveSubstatements(final Collection<? extends Mutable<?, ?, ?>> statements) {
if (!statements.isEmpty()) {
abstract @NonNull E createEffective(@NonNull StatementFactory<A, D, E> factory);
- /**
- * 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);
-
/**
* Return a stream of declared statements which can be built into an {@link EffectiveStatement}, as per
* {@link StmtContext#buildEffective()} contract.