Skip to content

Commit 6eec52a

Browse files
committed
[Migrator] Don't pick up missing argument type placeholder fix-its
With SE-110, the migrator may get a recommendation to add a Void placeholder in the call to f in: func foo(f: (Void) -> ()) { f() } Here, f was () -> () in Swift 3 but now (()) -> () in Swift 4. Adding a type placeholder in the f() call isn't helpful for migration, although this particular fix-it should be to fix the f parameter's type. rdar://problem/31895432
1 parent 1bc7e70 commit 6eec52a

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

include/swift/Migrator/FixitFilter.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,19 @@ struct FixitFilter {
7777
return false;
7878
}
7979

80+
// With SE-110, the migrator may get a recommendation to add a Void
81+
// placeholder in the call to f in:
82+
// func foo(f: (Void) -> ()) {
83+
// f()
84+
// }
85+
// Here, f was () -> () in Swift 3 but now (()) -> () in Swift 4. Adding a
86+
// type placeholder in the f() call isn't helpful for migration, although
87+
// this particular fix-it should be to fix the f parameter's type.
88+
if (Info.ID == diag::missing_argument_named.ID ||
89+
Info.ID == diag::missing_argument_positional.ID) {
90+
return false;
91+
}
92+
8093
if (Kind == DiagnosticKind::Error)
8194
return true;
8295

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
func foo(f: (Void) -> ()) {
2+
f()
3+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// RUN: rm -rf %t && mkdir -p %t && %target-swift-frontend -c -primary-file %S/Inputs/ignore_type_placeholder.swift -emit-migrated-file-path %t/ignore_type_placeholder.swift.result -emit-remap-file-path %t/ignore_type_placeholder.swift.remap
2+
// RUN: %FileCheck %s < %t/ignore_type_placeholder.swift.result
3+
// CHECK-NOT: f(<#Void#>)

0 commit comments

Comments
 (0)