I was informed about impossibility to use a polymorphic functions together with domain types
see
create domain xx as numeric(15);
create or replace function g(anyelement, anyelement) returns anyelement as $$ select $1 + $2 $$ language sql immutable;
postgres=# select g(1::xx, 2::xx); ERROR: return type mismatch in function declared to return xx DETAIL: Actual return type is numeric. CONTEXT: SQL function "g" during inlining