mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[CS] If locator points to a function call, then compare the fn and semanticFn, otherwise fall back to paren check
This is because otherwise we would have false positives, like 'Foo(Bar())' where Foo's init accepts a non-optional Bar and Bar's init returns an IUO
This commit is contained in:
@@ -2199,9 +2199,14 @@ void ConstraintSystem::resolveOverload(ConstraintLocator *locator,
|
||||
if (!type || !type->is<AnyFunctionType>())
|
||||
return false;
|
||||
|
||||
auto paren = getParentExpr(locator->getAnchor());
|
||||
auto result = paren ? isa<ParenExpr>(paren) : false;
|
||||
return result;
|
||||
if (auto call = dyn_cast<CallExpr>(locator->getAnchor()))
|
||||
return call->getSemanticFn() != call->getFn();
|
||||
|
||||
if (auto paren = getParentExpr(locator->getAnchor())) {
|
||||
return isa<ParenExpr>(paren);
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
// In some cases we already created the appropriate bind constraints.
|
||||
|
||||
Reference in New Issue
Block a user