forked from swiftlang/swift
- Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcatch_error.swift
20 lines (18 loc) · 719 Bytes
/
catch_error.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// REQUIRES: objc_interop
// RUN: %target-swift-frontend -Xllvm -sil-print-types -emit-sil -Xllvm -sil-print-debuginfo %s \
// RUN: -parse-as-library | %FileCheck %s
import Foundation
openclassCache<T>{
let_negativeCache:NSMutableDictionary=NSMutableDictionary()
func cachedValue(creationBlock:()throws->T)throws->T{
do{
letvalue=trycreationBlock()
return value
}catch{
// CHECK: debug_value {{.*}} : $any Error, let, name "error", loc "{{.*}}":[[@LINE-1]]:13, scope [[SCOPE:[0-9]+]]
// CHECK: alloc_stack $@opened({{.*}}, any Error) Self, loc{{.*}}, scope [[SCOPE]]
_negativeCache.setObject(error, forKey:NSNumber(1))
throw error
}
}
}