Skip to content

Commit 50de5a5

Browse files
committed
[NFC] ExistentialTypeSyntaxChecker: Document, rename and make existentialNeedsParens static
1 parent 5a2316c commit 50de5a5

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

lib/Sema/TypeCheckType.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6057,7 +6057,9 @@ class ExistentialTypeSyntaxChecker : public ASTWalker {
60576057
}
60586058

60596059
private:
6060-
bool existentialNeedsParens(TypeRepr *parent) const {
6060+
/// Returns a Boolean value indicating whether the insertion of `any` before
6061+
/// a type representation with the given parent requires paretheses.
6062+
static bool anySyntaxNeedsParens(TypeRepr *parent) {
60616063
switch (parent->getKind()) {
60626064
case TypeReprKind::Optional:
60636065
case TypeReprKind::Protocol:
@@ -6103,7 +6105,7 @@ class ExistentialTypeSyntaxChecker : public ASTWalker {
61036105
bool needsParens = (exprCount != 0);
61046106
if (reprStack.size() > 1) {
61056107
auto parentIt = reprStack.end() - 2;
6106-
needsParens = existentialNeedsParens(*parentIt);
6108+
needsParens = anySyntaxNeedsParens(*parentIt);
61076109

61086110
// Expand to include parenthesis before checking if the parent needs
61096111
// to be replaced.
@@ -6115,7 +6117,7 @@ class ExistentialTypeSyntaxChecker : public ASTWalker {
61156117
if ((*parentIt)->getKind() == TypeReprKind::Metatype) {
61166118
replaceRepr = *parentIt;
61176119
if (parentIt != reprStack.begin())
6118-
needsParens = existentialNeedsParens(*(parentIt - 1));
6120+
needsParens = anySyntaxNeedsParens(*(parentIt - 1));
61196121
}
61206122
}
61216123

0 commit comments

Comments
 (0)