Skip to content

Commit ce8c0eb

Browse files
authored
Merge pull request #10463 from bitjammer/rdar-32907276-migrator-no-dollar-zero-prefix
[Migrator] Remove closure shorthand prefixing.
2 parents e431e1a + 9c1fa89 commit ce8c0eb

File tree

2 files changed

+4
-14
lines changed

2 files changed

+4
-14
lines changed

lib/Migrator/TupleSplatMigratorPass.cpp

+1-11
Original file line numberDiff line numberDiff line change
@@ -96,20 +96,10 @@ struct TupleSplatMigratorPass : public ASTMigratorPass,
9696
}
9797

9898
unsigned ClosureArity = Closure->getParameters()->size();
99-
if (NativeArity == ClosureArity)
99+
if (NativeArity <= ClosureArity)
100100
return false;
101101

102102
ShorthandFinder Finder(Closure);
103-
if (NativeArity == 1 && ClosureArity > 1) {
104-
// Prepend $0. to existing references
105-
Finder.forEachReference([this](Expr *Ref, ParamDecl* Def) {
106-
if (auto *TE = dyn_cast<TupleElementExpr>(Ref))
107-
Ref = TE->getBase();
108-
SourceLoc AfterDollar = Ref->getStartLoc().getAdvancedLoc(1);
109-
Editor.insert(AfterDollar, "0.");
110-
});
111-
return true;
112-
}
113103

114104
if (ClosureArity == 1 && NativeArity > 1) {
115105
// Remove $0. from existing references or if it's only $0, replace it

test/Migrator/tuple-arguments.swift.expected

+3-3
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,14 @@ func toString(indexes: Int?...) -> String {
4646
})
4747
let _ = indexes.reduce(0) { print(($0, $1)); return $0 + ($1 ?? 0)}
4848
let _ = indexes.reduce(0) { (true ? ($0, $1) : (1, 2)).0 + ($1 ?? 0) }
49-
let _ = [(1, 2)].contains { $0.0 != $0.1 }
49+
let _ = [(1, 2)].contains { $0 != $1 }
5050
_ = ["Hello", "Foo"].sorted { print(($0, $1)); return $0.characters.count > $1.characters.count }
51-
_ = ["Hello" : 2].map { ($0.0, ($0.1)) }
51+
_ = ["Hello" : 2].map { ($0, ($1)) }
5252
}
5353

5454
extension Dictionary {
5555
public mutating func merge(with dictionary: Dictionary) {
56-
dictionary.forEach { updateValue($0.1, forKey: $0.0) }
56+
dictionary.forEach { updateValue($1, forKey: $0) }
5757
}
5858
}
5959

0 commit comments

Comments
 (0)