-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Description
Previous ID | SR-8036 |
Radar | None |
Original Reporter | mrwerdo (JIRA User) |
Type | Bug |
Status | Resolved |
Resolution | Won't Do |
Attachment: Download
Environment
Xcode
Version 10.0 beta (10L176w)
Swift Version
Apple Swift version 4.2 (swiftlang-1000.0.16.7 clang-1000.10.25.3)
Target: x86_64-apple-darwin17.6.0
Additional Detail from JIRA
Votes | 0 |
Component/s | Compiler |
Labels | Bug |
Assignee | None |
Priority | Medium |
md5: 05e05a93f64aace81cf33f2841e6c9e3
Issue Description:
Global variable's deinit methods are not called, but they should be.
The attached file produces the following output:
Read the image at: ~/Pictures/New York.png
Made the image black and white: ~/Pictures/New York.png
Read the image at: ~/Pictures/Sydney.png
Made the image black and white: ~/Pictures/Sydney.png
Saved the image: ~/Pictures/Sydney.png
There should be a second 'Save the image' line in the output, because there was two objects created.
The example also demonstrates how this problem can exhibit itself in real projects, files may not be saved/flushed before the program exits. Swift's guide actually lists this as a use case for `deinit` methods, "For example, if you create a custom class to open a file and write some data to it, you might need to close the file before the class instance is deallocated."