Skip to content

Commit 2c2038d

Browse files
committed
[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.
1 parent 55189ba commit 2c2038d

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5186,11 +5186,16 @@ bool ConstraintSystem::repairFailures(
51865186
// side isn't, let's check it would be possible to fix
51875187
// this by forming an explicit call.
51885188
auto convertTo = dstType->lookThroughAllOptionalTypes();
5189-
// Right-hand side can't be - a function, a type variable or dependent
5190-
// member, or `Any` (if function conversion to `Any` didn't succeed there
5191-
// is something else going on e.g. problem with escapiness).
5192-
if (convertTo->is<FunctionType>() || convertTo->isTypeVariableOrMember() ||
5193-
convertTo->isAny())
5189+
5190+
// If the RHS is a function type, the source must be a function-returning
5191+
// function.
5192+
if (convertTo->is<FunctionType>() && !resultType->is<FunctionType>())
5193+
return false;
5194+
5195+
// Right-hand side can't be a type variable or dependent member, or `Any`
5196+
// (if function conversion to `Any` didn't succeed there is something else
5197+
// going on e.g. problem with escapiness).
5198+
if (convertTo->isTypeVariableOrMember() || convertTo->isAny())
51945199
return false;
51955200

51965201
ConstraintKind matchKind;

0 commit comments

Comments
 (0)