- Notifications
You must be signed in to change notification settings - Fork 10.5k
/
Copy pathErrors.swift
35 lines (29 loc) · 1.27 KB
/
Errors.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// RUN: %target-swift-frontend %s -emit-ir -g -o - | %FileCheck %s
publicenumE:Error{case Err }
// Function throws.
publicfunc throwError()throws{throwE.Err }
// CHECK: !DISubprogram(name: "throwError", {{.*}}thrownTypes: ![[THROWN:.*]])
// CHECK-DAG: ![[THROWN]] = !{![[ERROR:[0-9]+]]}
// CHECK-DAG: ![[ERROR]] = !DICompositeType(tag: DW_TAG_structure_type, name: "Error"
// Function rethrows.
publicfunc rethrow(fn :(()throws->()))rethrows{tryfn()}
// CHECK: !DISubprogram(name: "rethrow", {{.*}}thrownTypes: ![[THROWN:.*]])
publicclassC{
// Initializer throws.
init()throws{throwE.Err }
// CHECK: !DISubprogram(name: "init", {{.*}}line: [[@LINE-1]],
// CHECK-SAME: thrownTypes: ![[THROWN:.*]])
// Initializer rethrows.
init(fn :(()throws->()))rethrows{
// CHECK: !DISubprogram(name: "init", {{.*}}line: [[@LINE-1]],
// CHECK-SAME: thrownTypes: ![[THROWN:.*]])
tryfn()
}
}
// Negative tests.
// CHECK: !DISubprogram(name: "returnThrowing",
// CHECK-NOT: thrownTypes:
publicfunc returnThrowing()->(()throws->()){return throwError }
// CHECK: !DISubprogram(name: "takesThrowing",
// CHECK-NOT: thrownTypes:
publicfunc takesThrowing(fn :(()throws->())){}