[SR-3530] Nested self-capturing function interferes with a call to isKnownUniquelyReferenced(_:) #46118
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
compiler
The Swift compiler in itself
performance
Environment
Apple Swift version 3.0.2 (swiftlang-800.0.63 clang-800.0.42.1)
Target: x86_64-apple-macosx10.9
Additional Detail from JIRA
md5: b07c484b53a633a4d173cca9a7ed79a1
Issue Description:
The following code always prints false, even though the capturing appears as if it should be happening after the call to isKnownUniquelyReferenced:
From what I can tell, self is getting alloc_box'ed too early (really shouldn't be boxed at all given that Swift prevents nestedFunc from escaping). This can break implementations that utilise isKnownUniquelyReferenced to optimise copy-on-write, in a rather non-obvious manner.
The text was updated successfully, but these errors were encountered: