@Override public <X, Y extends DeclaredStatement<X>, Z extends EffectiveStatement<X, Y>> Mutable<X, Y, Z> childCopyOf( final StmtContext<X, Y, Z> stmt, final CopyType type, final QNameModule targetModule) { checkState(stmt.getCompletedPhase() == ModelProcessingPhase.EFFECTIVE_MODEL, "Attempted to copy statement %s which has completed phase %s", stmt, stmt.getCompletedPhase()); checkArgument(stmt instanceof SubstatementContext, "Unsupported statement %s", stmt); final SubstatementContext<X, Y, Z> original = (SubstatementContext<X, Y, Z>)stmt; final SubstatementContext<X, Y, Z> copy = new SubstatementContext<>(original, this, type, targetModule); original.definition().onStatementAdded(copy); original.copyTo(copy, type, targetModule); return copy; }