Skip to content

Commit 6c359cc

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 563ce3c commit 6c359cc

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
@@ -863,7 +863,6 @@ ParameterListInfo::ParameterListInfo(
863863
const ValueDecl *paramOwner,
864864
bool skipCurriedSelf) {
865865
defaultArguments.resize(params.size());
866-
acceptsUnlabeledTrailingClosures.resize(params.size());
867866

868867
// No parameter owner means no parameter list means no default arguments
869868
// - hand back the zeroed bitvector.
@@ -896,6 +895,10 @@ ParameterListInfo::ParameterListInfo(
896895
if (params.size() != paramList->size())
897896
return;
898897

898+
// Now we have enough information to determine which parameters accept
899+
// unlabled trailing closures.
900+
acceptsUnlabeledTrailingClosures.resize(params.size());
901+
899902
// Note which parameters have default arguments and/or accept unlabeled
900903
// trailing closure arguments with the forward-scan rule.
901904
for (auto i : range(0, params.size())) {
@@ -917,7 +920,7 @@ bool ParameterListInfo::hasDefaultArgument(unsigned paramIdx) const {
917920

918921
bool ParameterListInfo::acceptsUnlabeledTrailingClosureArgument(
919922
unsigned paramIdx) const {
920-
return paramIdx < acceptsUnlabeledTrailingClosures.size() &&
923+
return paramIdx >= acceptsUnlabeledTrailingClosures.size() ||
921924
acceptsUnlabeledTrailingClosures[paramIdx];
922925
}
923926

0 commit comments

Comments
 (0)