mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Migrator/QoI: Function input type: Don't fix Void to (Void), but fix (Void) to ()
```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
This commit is contained in:
@@ -90,6 +90,12 @@ struct FixitFilter {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Trying to add '_ in' to a closure signature can be counterproductive when
|
||||
// fixing function signatures like (Void) -> () to () -> ().
|
||||
if (Info.ID == diag::closure_argument_list_missing.ID) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Kind == DiagnosticKind::Error)
|
||||
return true;
|
||||
|
||||
@@ -120,7 +126,8 @@ struct FixitFilter {
|
||||
Info.ID == diag::override_swift3_objc_inference.ID ||
|
||||
Info.ID == diag::objc_inference_swift3_objc_derived.ID ||
|
||||
Info.ID == diag::missing_several_cases.ID ||
|
||||
Info.ID == diag::missing_particular_case.ID)
|
||||
Info.ID == diag::missing_particular_case.ID ||
|
||||
Info.ID == diag::paren_void_probably_void.ID)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user