SI-5900 Fix pattern inference regression

Rebase #3514