Assume that you need to calculate $I=\int_\gamma (P\,dx +Q\,dy)$ and $P=U_x$, $Q=U_y$. Then $P\,dx +Q\,dy= dU$ and $I= U(x_1,y_1)-U(x_0,y_0)$ where $\gamma$ goes from $(x_0,y_0)$ to $(x_1,y_1)$. So far there is no analytic functions or simple connectivity of the domain.

However $P=U_x$, $Q=U_y$ implies $P_y=Q_x$. If we integrate $f\,dz$ then $P=f$, $Q=if$ and this is equivalent to $f_y=if_x$ which is a Cauchy-Riemann condition (plug $f=u+iv$).

Further, if domain is not simply connected, then even "$f$ is analytic" does not imply that there exists an analytic single-valued function $F$ such that $F'=f$ (for non-analytic functions the "derivative": is not defined). F.e. in $\mathbb{C}\setminus 0$ let $f=z^{-1}$; then $F=\log (z)$ is a multivalued function and $I$ is an increment of $F$ along $\gamma$, depending on $\gamma$ (more precisely, it depends on the equivalency class $[\gamma]$ of $\gamma$: $\gamma_1 \sim \gamma_2$ if one could be continuously morphed into another without leaving domain. Only in simple connected domains all curves with the same start and end points are equivalent.