Backport Split evaluation of 'dist' and 'and/or/xor' constraints in class promises from master to 3.4

This is a backport of commit 220782476c1d682767ea4c8ff878c5f22c9f06c5 from Mikhail Gusarov