fix Issue 6312 - template instance cannot use argument from enclosing template
Merge pull request #1850 from 9rnsr/fix6312

Issue 6312 - template instance cannot use argument from enclosing template