[CS] Allow InsertExplicitCall for higher-order functions

Allow `InsertExplicitCall` for e.g converting
`() -> () -> Void` to `() -> Void`. No test since
it's already covered in the test suite when the
next commit is applied.
This commit is contained in:
Hamish Knight
2024-12-29 12:25:18 +00:00
parent 55189bae8e
commit 2c2038d459

View File

@@ -5186,11 +5186,16 @@ bool ConstraintSystem::repairFailures(
// side isn't, let's check it would be possible to fix // side isn't, let's check it would be possible to fix
// this by forming an explicit call. // this by forming an explicit call.
auto convertTo = dstType->lookThroughAllOptionalTypes(); auto convertTo = dstType->lookThroughAllOptionalTypes();
// Right-hand side can't be - a function, a type variable or dependent
// member, or `Any` (if function conversion to `Any` didn't succeed there // If the RHS is a function type, the source must be a function-returning
// is something else going on e.g. problem with escapiness). // function.
if (convertTo->is<FunctionType>() || convertTo->isTypeVariableOrMember() || if (convertTo->is<FunctionType>() && !resultType->is<FunctionType>())
convertTo->isAny()) return false;
// Right-hand side can't be a type variable or dependent member, or `Any`
// (if function conversion to `Any` didn't succeed there is something else
// going on e.g. problem with escapiness).
if (convertTo->isTypeVariableOrMember() || convertTo->isAny())
return false; return false;
ConstraintKind matchKind; ConstraintKind matchKind;