mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
```swift
func foo(f: Void) -> ()) {}
```
This compiler currently suggests we change this to:
```swift
func foo(f: (Void) -> ()) {}
```
That's `(()) -> ()`, almost certainly not what someone wants in Swift
4. We should suggest changing that to:
```swift
func foo(f: () -> ()) {}
```
Additionally,
```swift
func foo(f: (Void) -> ()) {}
```
Should trigger a warning that the `(Void)` input type is `(())`, and you
can't supply `()` to it in Swift 4, and suggest a fix-it change it to:
```swift
func foo(f: () -> ()) {}
```
rdar://problem/32143617
18 lines
478 B
Swift
18 lines
478 B
Swift
// 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 -swift-version 3
|
|
// RUN: diff -u %s.expected %t.result
|
|
// RUN: %target-swift-frontend -typecheck %s.expected -swift-version 4
|
|
|
|
func takesNothing(_ f: () -> ()) {
|
|
f()
|
|
f(())
|
|
}
|
|
|
|
func takesVoidFunction(_ f: (Void) -> ()) {
|
|
f()
|
|
f(())
|
|
}
|
|
|
|
takesNothing { print("Hello") }
|
|
takesVoidFunction { print("Hello") }
|