mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
We weren't renaming all occurrences of 'x' in the cases like the below:
case .first(let x), .second(let x):
print("foo \(x)")
fallthrough
case .third(let x):
print("bar \(x)")
We would previously only rename occurrences within the case statement the query
was made in (ignoring fallthroughs) and for cases with multiple patterns (as in
the first case above) we would only rename the occurrence in the first pattern.
50 lines
757 B
Plaintext
50 lines
757 B
Plaintext
func test1() {
|
|
if true {
|
|
let x = 1
|
|
print(x)
|
|
} else {
|
|
let x = 2
|
|
print(x)
|
|
}
|
|
}
|
|
|
|
func test2(arg1: Int?, arg2: (Int, String)?) {
|
|
if let x = arg1 {
|
|
print(x)
|
|
} else if let (x, y) = arg2 {
|
|
print(x, y)
|
|
}
|
|
}
|
|
|
|
func test3(arg: Int?) {
|
|
switch arg {
|
|
case let .some(x) where x == 0:
|
|
print(x)
|
|
case let .some(xRenamed) where xRenamed == 1,
|
|
let .some(xRenamed) where xRenamed == 2:
|
|
print(xRenamed)
|
|
fallthrough
|
|
case let .some(xRenamed) where xRenamed == 3:
|
|
print(xRenamed)
|
|
default:
|
|
break
|
|
}
|
|
}
|
|
|
|
struct Err1 : Error { }
|
|
func test4(arg: () throws -> Void) {
|
|
do {
|
|
try arg()
|
|
} catch let x as Err1 {
|
|
print(x)
|
|
} catch let x {
|
|
print(x)
|
|
}
|
|
}
|
|
|
|
func test5(_ x: Int) {
|
|
let x = x
|
|
print(x)
|
|
}
|
|
|