fix Issue 10074 - segfault in dmd

From 2.061, `deduceFunctionTemplate` has been using TemplateDeclaration::matchWithInstance to do IFTI more strictly.
However, `matchWithInstance` does not detect the recursive template instantiation inside template constraint, against `deduceFunctionTemplateMatch`.

Duplicate the detection mechanism into `matchWithInstance`.