mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Record throwing property accesses as potential throw sites
This commit is contained in:
@@ -196,12 +196,24 @@ struct ThrowingMembers {
|
||||
subscript(i: Int) -> Int {
|
||||
get throws(MyError) { i }
|
||||
}
|
||||
|
||||
var intOrThrows: Int {
|
||||
get throws(MyError) { 5 }
|
||||
}
|
||||
}
|
||||
|
||||
struct ThrowingStaticSubscript {
|
||||
static subscript(i: Int) -> Int {
|
||||
get throws(MyError) { i }
|
||||
}
|
||||
|
||||
static var intOrThrows: Int {
|
||||
get throws(MyError) { 5 }
|
||||
}
|
||||
}
|
||||
|
||||
var globalIntOrThrows: Int {
|
||||
get throws(MyError) { 5 }
|
||||
}
|
||||
|
||||
func testDoCatchInClosure(cond: Bool, x: ThrowingMembers) {
|
||||
@@ -262,4 +274,29 @@ func testDoCatchInClosure(cond: Bool, x: ThrowingMembers) {
|
||||
let _: MyError = error
|
||||
}
|
||||
}
|
||||
|
||||
// Property accesses as potential throw sites
|
||||
apply {
|
||||
do {
|
||||
_ = try x.intOrThrows
|
||||
} catch {
|
||||
let _: MyError = error
|
||||
}
|
||||
}
|
||||
|
||||
apply {
|
||||
do {
|
||||
_ = try ThrowingStaticSubscript.intOrThrows
|
||||
} catch {
|
||||
let _: MyError = error
|
||||
}
|
||||
}
|
||||
|
||||
apply {
|
||||
do {
|
||||
_ = try globalIntOrThrows
|
||||
} catch {
|
||||
let _: MyError = error
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user