[BZ-1078839] eveluate more specific cases first when expanding a DSL
(cherry picked from commit 1fe0f6d9a9053809239ff65b859b5ab39ea26164)