Skip to content

Commit 3243c52

Browse files
committed
Lacking parameter declarations, and parameter accepts trailing closures
When we are performing a call through a value of function type, rather than calling a particular declaration that has parameter declarations, allow any parameter to accept trailing closures.
1 parent 676e9df commit 3243c52

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lib/AST/Type.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -853,7 +853,6 @@ ParameterListInfo::ParameterListInfo(
853853
const ValueDecl *paramOwner,
854854
bool skipCurriedSelf) {
855855
defaultArguments.resize(params.size());
856-
acceptsUnlabeledTrailingClosures.resize(params.size());
857856

858857
// No parameter owner means no parameter list means no default arguments
859858
// - hand back the zeroed bitvector.
@@ -892,6 +891,10 @@ ParameterListInfo::ParameterListInfo(
892891
if (params.size() != paramList->size())
893892
return;
894893

894+
// Now we have enough information to determine which parameters accept
895+
// unlabled trailing closures.
896+
acceptsUnlabeledTrailingClosures.resize(params.size());
897+
895898
// Note which parameters have default arguments and/or accept unlabeled
896899
// trailing closure arguments with the forward-scan rule.
897900
for (auto i : range(0, params.size())) {
@@ -913,7 +916,7 @@ bool ParameterListInfo::hasDefaultArgument(unsigned paramIdx) const {
913916

914917
bool ParameterListInfo::acceptsUnlabeledTrailingClosureArgument(
915918
unsigned paramIdx) const {
916-
return paramIdx < acceptsUnlabeledTrailingClosures.size() &&
919+
return paramIdx >= acceptsUnlabeledTrailingClosures.size() ||
917920
acceptsUnlabeledTrailingClosures[paramIdx];
918921
}
919922

0 commit comments

Comments
 (0)