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
722 B
Plaintext
50 lines
722 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(xRenamed) where xRenamed == 0:
|
|
print(xRenamed)
|
|
case let .some(x) where x == 1,
|
|
let .some(x) where x == 2:
|
|
print(x)
|
|
fallthrough
|
|
case let .some(x) where x == 3:
|
|
print(x)
|
|
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)
|
|
}
|
|
|