Skip to content

Commit b5568e0

Browse files
committed
[CSGen] Allow closure parameters to become holes by default
That helps when there is no context around a closure and parameters used in the body are untyped.
1 parent f32cb61 commit b5568e0

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/Sema/CSGen.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2191,8 +2191,12 @@ namespace {
21912191
auto declaredTy = param->getType();
21922192
externalType = CS.openUnboundGenericType(declaredTy, paramLoc);
21932193
} else {
2194+
// Let's allow parameters which haven't been explicitly typed
2195+
// to become holes by default, this helps in situations like
2196+
// `foo { a in }` where `foo` doesn't exist.
21942197
externalType = CS.createTypeVariable(
2195-
paramLoc, TVO_CanBindToInOut | TVO_CanBindToNoEscape);
2198+
paramLoc,
2199+
TVO_CanBindToInOut | TVO_CanBindToNoEscape | TVO_CanBindToHole);
21962200
}
21972201

21982202
closureParams.push_back(param->toFunctionParam(externalType));

0 commit comments

Comments
 (0)