forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 354
Open
Labels
Description
| Previous ID | SR-15128 |
| Radar | rdar://problem/82543261 |
| Original Reporter | dalk (JIRA User) |
| Type | Bug |
Environment
xcode 12.5.0
Additional Detail from JIRA
| Votes | 0 |
| Component/s | Compiler, LLDB for Swift |
| Labels | Bug |
| Assignee | @adrian-prantl |
| Priority | Medium |
md5: 1411048b52a88fb0a49aecc05e14bcc1
Issue Description:
100 % reproducible crash when compiling this piece of code. Please note that if MyClass is a struct, it doesnt crash. Same if we change "if let entry = entry" to "if let anything = entry"
class MyClass {
**let** value: Int
**init**(value: Int)
{ self.value = value }
}
func test() {
**let** cachedImages: ThreadSafeMap\<String, MyClass\> = ThreadSafeMap\<String, MyClass\>(label: "")
**let** entry = cachedImages.get(key: "toto")
**guard** **let** entry = entry **else**
{ return }
}
public class ThreadSafeMap<T: Hashable, U: AnyObject> {
**private** **var** map: \[T: U\] = \[:\]
**private** **let** cacheAccessQueue: DispatchQueue
**public** **init**(label: String)
{ self.cacheAccessQueue = DispatchQueue(label: label, qos: .userInitiated, attributes: .concurrent) }
**public** **func** get(key: T) -\> U? {
cacheAccessQueue.sync
{ return map[key] }
}
}