GEOT-4916: improve checks on domain types: backport to 12.x