Macau, a former Portuguese colony, is full of these pastries. This may be how they entered China...
Custard tarts derived from the Portuguese pastry were
introduced in Hong Kong in the 1940s by cha chaan tengs
via the Portuguese colony of Macau.
https://en.wikipedia.org/wiki/Egg_tart#History