Perhaps not strictly following that order, but perhaps if Cardinal-Infante Henrique of Portugal was elected Pope and then subsequently inherited the throne, similarly to OTL, you could have a fun test case on whether a Pope could be a King simultaneously.
I have my doubts that a former ruler would get so far as the curia, much less actually become Pope. I know of a few that abdicated and retired to a monastery, but that's about it.