Fix static chain issues

This fixes some static chain issues. Test cases are attached. I'm not sure if all test cases actually fail on gdc-4.8 right now, but they do fail on gdc-4.7 and I think the changes are not specific to gcc-4.7.

Fixed problems:
* Nested functions in template instances get a static chain
* Non-static nested structs get chains just like classes
* Template instances with alias this now get a correct chain
* "Degenerate" closures are handled
* nested template instance functions are marked as one-only