The SILGen testsuite consists of valid Swift code covering most language
features. We use these tests to verify that no unknown nodes are in the
file's libSyntax tree. That way we will (hopefully) catch any future
changes or additions to the language which are not implemented in
libSyntax.
SILGen emits 'var' bindings as mutable heap-allocated boxes,
since they might be captured by escaping closures whose
lifetime exceeds that of the function itself.
Escaping closures capture the entire box; however for noescape
closures it is sufficient to capture only the address projected
from the box, because usually the box outlives the closure.
The one exception though is if the binding is introduced by
a capture list. In this case, the closure would outlive the box,
resulting in the contents of the box being released before the
closure was invoked.
Normally, capture lists cannot introduce 'var' bindings; the
one exception is when capturing a reference as 'weak'.
Fix the problem by capturing such bindings as a box and not as a
projection, even for noescape closures.
Fixes <rdar://problem/32718153>.