Skip to content

Commit 7032095

Browse files
committed
[TypeChecker] Tighten up validation of dynamic member decls
Make sure that base decl is valid and that parameter has a valid signature.
1 parent 675c5f4 commit 7032095

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

lib/Sema/TypeCheckAttr.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -977,7 +977,11 @@ visitDynamicCallableAttr(DynamicCallableAttr *attr) {
977977

978978
static bool hasSingleNonVariadicParam(SubscriptDecl *decl) {
979979
auto *indices = decl->getIndices();
980-
return indices->size() == 1 && !indices->get(0)->isVariadic();
980+
if (decl->isInvalid() || indices->size() != 1)
981+
return false;
982+
983+
auto *index = indices->get(0);
984+
return !index->isVariadic() && index->hasValidSignature();
981985
}
982986

983987
/// Returns true if the given subscript method is an valid implementation of
@@ -1020,9 +1024,6 @@ bool swift::isValidKeyPathDynamicMemberLookup(SubscriptDecl *decl,
10201024
return false;
10211025

10221026
const auto *param = decl->getIndices()->get(0);
1023-
if (param->isVariadic())
1024-
return false;
1025-
10261027
if (auto NTD = param->getType()->getAnyNominal()) {
10271028
return NTD == TC.Context.getKeyPathDecl() ||
10281029
NTD == TC.Context.getWritableKeyPathDecl();

0 commit comments

Comments
 (0)