Whitney's extension theorem states that if $D \subset \mathbb{R}^n$ is closed and $f: D \to \mathbb{R}$ is $C^k$ in some sense to be specified below, then $f$ can be extended to $\mathbb{R}^n$ so that it is real analytic on $D^c$. Now let me specify what it means to be $C^k$ in the sense that we want - we will call this Whitney $C^k$.
We say that $f: D \to \mathbb{R}$ is Whitney $C^k$ (on $D$) if there exist functions $f_\alpha: D \to \mathbb{R}$, $|\alpha| \le k$ (note here $\alpha$ is a multindex with $n$ entries) s.t. for all $x,y \in D$ and $\alpha \in \mathbb{Z}^n$, $$f_\alpha (x) = \sum_{|\beta| \le k-|\alpha|} \frac{f_{\alpha + \beta}(y)}{\beta !} (x-y)^\beta +R_\alpha(x,y)$$ with $R_\alpha$ having the following property: Given any point $z \in D$ and any $\epsilon > 0$ there exists a $\delta > 0$ s.t. if $x, y \in A$ and $|z-x|< \delta$ and $|z-y|< \delta$ then $|R_\alpha (x,y)| \le \epsilon |x-y|^{k-|\alpha|}$.
Now for my question. I am wondering for what closed sets can we say that if $f$ is $C^k$ (see the Edit below for definition) then it is Whitney $C^k$. Phrased differently, I am wondering for what closed sets (with $C^k$ functions defined on these sets) can we apply Whitney's extension theorem.
I have been able to show that if $D$ is the closure on an open bounded convex set and $f: D \to \mathbb{R}$ is $C^k$ then $f$ is Whitney $C^k$. To see this one applies the multivariable Taylor's theorem (integral version- see here https://en.wikipedia.org/wiki/Taylor%27s_theorem#Taylor.27s_theorem_for_multivariate_functions). Notice that the proof, and therefore the estimates, rely on integrating along a line segment - this is where convexity is used. I suspect this can be generalized to $D$ being the closure of a connected open set with suitably smooth boundary (i.e. $C^\infty$).
References are also appreciated.
Edit: For completeness, let me add the definition of $C^k$ on the closure of an open set. Let $U$ be an open set, then $f: \overline{U} \to \mathbb{C}$ is $C^k$ if all the partial derivative of $f$ up to order $k$ extend continuously to $\overline{U}$.