Skip to content

Commit 726adfb

Browse files
committed
[Migrator] Don't pick up extraneous argument label fix-it
This can be incorrectly reported by the type-checker when argument arity doesn't match in trailing closure arguments. This diagnostic isn't generally useful for the migrator. rdar://problem/32477119 rdar://problem/32432254
1 parent ee4293f commit 726adfb

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

include/swift/Migrator/FixitFilter.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,12 @@ struct FixitFilter {
9696
return false;
9797
}
9898

99+
// The type-checker can erroneously report this diagnostic in the case of
100+
// mismatching closure arguments to things that now take a tuple via SE-0110.
101+
if (Info.ID == diag::extra_argument_labels.ID) {
102+
return false;
103+
}
104+
99105
if (Kind == DiagnosticKind::Error)
100106
return true;
101107

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// RUN: %target-swift-frontend -typecheck %s -swift-version 3
2+
// RUN: rm -rf %t && mkdir -p %t && %target-swift-frontend -c -primary-file %s -emit-migrated-file-path %t/no_extraneous_argument_labels.result -swift-version 3 -o /dev/null
3+
// RUN: diff -u %s.expected %t/no_extraneous_argument_labels.result
4+
// RUN: not %target-swift-frontend -typecheck %s.expected -swift-version 4
5+
6+
func foo(_ oc: [String]) {
7+
var args: [String] = []
8+
let dictionary: [String: String] = [:]
9+
args.append(contentsOf: oc.map { orderedColumn in
10+
dictionary.first { (column, value) in true }!.value
11+
})
12+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// RUN: %target-swift-frontend -typecheck %s -swift-version 3
2+
// RUN: rm -rf %t && mkdir -p %t && %target-swift-frontend -c -primary-file %s -emit-migrated-file-path %t/no_extraneous_argument_labels.result -swift-version 3 -o /dev/null
3+
// RUN: diff -u %s.expected %t/no_extraneous_argument_labels.result
4+
// RUN: not %target-swift-frontend -typecheck %s.expected -swift-version 4
5+
6+
func foo(_ oc: [String]) {
7+
var args: [String] = []
8+
let dictionary: [String: String] = [:]
9+
args.append(contentsOf: oc.map { orderedColumn in
10+
dictionary.first { (column, value) in true }!.value
11+
})
12+
}

0 commit comments

Comments
 (0)