Sema: Fix inconsistent behavior with SE-0110-related compatibility hack

Back when SE-0110 was implemented we decided that passing a function value
taking multiple parameters would be allowed where a function value taking
a single tuple argument was expected.

Due to quirks in the old function type representation, the "splat" in the
other direction sometimes worked too. When we redid the function type
representation we added a simulation of the old quirk for -swift-version 4
mode.

However this simulation was itself problematic because it only worked when
the function value being passed was a non-overloaded declaration reference.

Slightly broaden the hack to the overloaded case, to prevent user
confusion when adding or removing overloads.
This commit is contained in:
Slava Pestov
2019-02-21 09:42:38 -05:00
parent 82c33dc031
commit 6d19f7e0f4
3 changed files with 17 additions and 1 deletions

View File

@@ -1184,7 +1184,10 @@ ConstraintSystem::matchFunctionTypes(FunctionType *func1, FunctionType *func2,
// We somehow let tuple unsplatting function conversions
// through in some cases in Swift 4, so let's let that
// continue to work, but only for Swift 4.
if (simplified && isa<DeclRefExpr>(simplified)) {
if (simplified &&
(isa<DeclRefExpr>(simplified) ||
isa<OverloadedDeclRefExpr>(simplified) ||
isa<UnresolvedDeclRefExpr>(simplified))) {
implodeParams(func2Params);
}
}