Open
Description
Previous ID | SR-3471 |
Radar | rdar://problem/31857596 |
Original Reporter | ian.guedesmaia (JIRA User) |
Type | Bug |
Attachment: Download
Environment
XCode 8.2, iOS 9, iOS 10
Additional Detail from JIRA
Votes | 0 |
Component/s | Compiler, Foundation |
Labels | Bug, OptimizedOnly |
Assignee | ian.guedesmaia (JIRA) |
Priority | Medium |
md5: 48c176c2bd03a42277095b94ef0e9914
Issue Description:
The code below behaves differently on debug builds and on release builds. I'm not sure about the specific configuration that is causing it, but I can reproduce it quite easily.
@objc
protocol Observer: NSObjectProtocol {
func didUpdate()
}
class UserSession: NSObject {
fileprivate let observers: NSHashTable<Observer> = NSHashTable.weakObjects()
fileprivate func notifyObserversAboutUpdate() {
for observer in self.observers.setRepresentation {
//this cast succeeds on debug but fails on release
if let observer = observer as? Observer {
observer.didUpdate()
}
}
}
}