Skip to content

Commit 3479806

Browse files
committed
Fix regression from hack for SR-6796.
That hack resulted in already matching argument and parameter to end up not matching in this case. Fixes https://bugs.swift.org/browse/SR-7191 and rdar://problem/38798063
1 parent 18b28b9 commit 3479806

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1207,8 +1207,13 @@ ConstraintSystem::matchFunctionTypes(FunctionType *func1, FunctionType *func2,
12071207
if (last->getKind() == ConstraintLocator::ApplyArgToParam) {
12081208
if (auto *paren1 = dyn_cast<ParenType>(func1Input.getPointer())) {
12091209
auto innerTy = paren1->getUnderlyingType();
1210-
if (func2Input->isVoid() && innerTy->isVoid())
1210+
if (func2Input->isVoid() && innerTy->isVoid()) {
12111211
func1Input = innerTy;
1212+
// If the other input is also parenthesized, remove one
1213+
// layer of parens from it as well.
1214+
if (auto *paren2 = dyn_cast<ParenType>(func2Input.getPointer()))
1215+
func2Input = paren2->getUnderlyingType();
1216+
}
12121217
}
12131218
}
12141219
}

test/Compatibility/tuple_arguments_4.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1670,3 +1670,13 @@ do {
16701670
func h(_: ()) {} // expected-note {{'h' declared here}}
16711671
h() // expected-error {{missing argument for parameter #1 in call}}
16721672
}
1673+
1674+
1675+
// https://bugs.swift.org/browse/SR-7191
1676+
class Mappable<T> {
1677+
init(_: T) { }
1678+
func map<U>(_ body: (T) -> U) -> U { fatalError() }
1679+
}
1680+
1681+
let x = Mappable(())
1682+
_ = x.map { (_: Void) in return () }

0 commit comments

Comments
 (0)