Properly handle conversions to non typename types.

Closes #1060
Merge remote-tracking branch 'origin/master'

* origin/master:
  add failing test cases from #1038