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:
David Farler
2017-05-13 17:36:28 -07:00
parent c99c9c37f0
commit 0c48f71384
9 changed files with 97 additions and 11 deletions

View File

@@ -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;