mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
This allows the debugger to display them alongside the function's return value when finish-ing a function. rdar://problem/29481673
37 lines
1.3 KiB
Swift
37 lines
1.3 KiB
Swift
// RUN: %target-swift-frontend %s -emit-ir -g -o - | %FileCheck %s
|
|
public enum E : Error { case Err }
|
|
|
|
// Function throws.
|
|
public func throwError() throws { throw E.Err }
|
|
// CHECK: !DISubprogram(name: "throwError", {{.*}}thrownTypes: ![[THROWN:.*]])
|
|
// CHECK: ![[THROWN]] = !{![[ERROR:[0-9]+]]}
|
|
// CHECK: ![[ERROR]] = !DICompositeType(tag: DW_TAG_structure_type,
|
|
// CHECK-SAME: name: "Error"
|
|
|
|
|
|
// Function rethrows.
|
|
public func rethrow(fn : (() throws -> ())) rethrows { try fn() }
|
|
// CHECK: !DISubprogram(name: "rethrow", {{.*}}thrownTypes: ![[THROWN:.*]])
|
|
|
|
public class C {
|
|
// Initializer throws.
|
|
init() throws { throw E.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:.*]])
|
|
try fn()
|
|
}
|
|
}
|
|
|
|
// Negative tests.
|
|
// CHECK: !DISubprogram(name: "returnThrowing",
|
|
// CHECK-NOT: thrownTypes:
|
|
public func returnThrowing() -> (() throws -> ()) { return throwError }
|
|
// CHECK: !DISubprogram(name: "takesThrowing",
|
|
// CHECK-NOT: thrownTypes:
|
|
public func takesThrowing(fn : (() throws -> ())) {}
|