Created
February 23, 2019 03:00
-
-
Save mayoff/2c788003c1b5161da36bec807cc2a8e5 to your computer and use it in GitHub Desktop.
test Swift unowned safety
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyObject { } | |
var o = MyObject() | |
print("strong o = \(o)") | |
unowned let u = o | |
print("unowned u = \(u)") | |
o = MyObject() | |
print("new strong o = \(o)") | |
print("old unowned u = \(u)") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@robertmryan Ah interesting! Sorry, I missed that part in your original post. Upon re-inspection, you get the same behaviour in 4.2 and 5.0 – it just appears to be sometimes hitting the runtime error and sometimes crashing with EXC_BAD_ACCESS. Digging a bit further, when running with an assert Swift runtime it trips an assertion.
Filed a bug: SR-9999.