mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
The migrator pass that converts single-argument function input types doesn't handle the case when the function input has a label and is therefore a tuple. Expand it to handle that possibility. rdar://problem/32477319
62 lines
2.0 KiB
Plaintext
62 lines
2.0 KiB
Plaintext
// RUN: %target-swift-frontend -typecheck %s -swift-version 3
|
|
// RUN: %target-swift-frontend -typecheck -update-code -primary-file %s -emit-migrated-file-path %t.result -disable-migrator-fixits -swift-version 3
|
|
// RUN: diff -u %s.expected %t.result
|
|
// RUN: %target-swift-frontend -typecheck %s.expected -swift-version 4
|
|
|
|
func test1(_: ()) {}
|
|
test1(())
|
|
test1(())
|
|
func test2() {}
|
|
test2()
|
|
|
|
enum Result<T> {
|
|
case success(T)
|
|
}
|
|
func test3(_: Result<()>) {}
|
|
test3(.success(()))
|
|
|
|
func test4(_: (Int, Int) -> ()) {}
|
|
test4({ (x,y) in })
|
|
func test5(_: (Int, Int, Int) -> ()) {}
|
|
test5({ (x,y,z) in })
|
|
|
|
func test6(_: ((Int, Int)) -> ()) {}
|
|
test6({ let (x,y) = $0; })
|
|
func test7(_: ((Int, Int, Int)) -> ()) {}
|
|
test7({ let (x,y,z) = $0; })
|
|
test6({ let (x, y) = $0; })
|
|
test6({ let (_, _) = $0; })
|
|
test6({ (__val:(Int, Int)) in let (x,y) = __val; })
|
|
test6({ (__val:(Int, Int)) ->() in let (_,_) = __val; })
|
|
|
|
func test8(_: ((Int, Int)) -> Int) {}
|
|
test8 { (__val:(Int, Int)) -> Int in let (_,_) = __val; return 2 }
|
|
test8 { let (x, y) = $0; return x }
|
|
|
|
func isEven(_ x: Int) -> Bool { return x % 2 == 0 }
|
|
let items = Array(zip(0..<10, 0..<10))
|
|
_ = items.filter { let (_, x) = $0; return isEven(x) }
|
|
_ = items.filter { _ in true }
|
|
|
|
func toString(indexes: Int?...) -> String {
|
|
let _ = indexes.enumerated().flatMap({ (__val:(Int, Int?)) -> String? in let (i,index) = __val;
|
|
let _: Int = i
|
|
if index != nil {}
|
|
return ""
|
|
})
|
|
let _ = indexes.reduce(0) { print(($0, $1)); return $0 + ($1 ?? 0)}
|
|
let _ = indexes.reduce(0) { (true ? ($0, $1) : (1, 2)).0 + ($1 ?? 0) }
|
|
let _ = [(1, 2)].contains { $0.0 != $0.1 }
|
|
_ = ["Hello", "Foo"].sorted { print(($0, $1)); return $0.characters.count > $1.characters.count }
|
|
_ = ["Hello" : 2].map { ($0.0, ($0.1)) }
|
|
}
|
|
|
|
extension Dictionary {
|
|
public mutating func merge(with dictionary: Dictionary) {
|
|
dictionary.forEach { updateValue($0.1, forKey: $0.0) }
|
|
}
|
|
}
|
|
|
|
let dictionary: [String: String] = [:]
|
|
_ = dictionary.first { let (column, value) = $0; return true }!.value
|