Skip to content

Commit 05fe333

Browse files
committed
[NFC] Redo TypeBase::isTypeVariableOrMember/isTypeParameter Without Recursion
1 parent 3b66a31 commit 05fe333

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

include/swift/AST/Types.h

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6283,21 +6283,22 @@ inline ASTContext &TypeBase::getASTContext() {
62836283
}
62846284

62856285
inline bool TypeBase::isTypeVariableOrMember() {
6286-
if (is<TypeVariableType>())
6287-
return true;
6286+
Type t(this);
62886287

6289-
if (auto depMemTy = getAs<DependentMemberType>())
6290-
return depMemTy->getBase()->isTypeVariableOrMember();
6288+
while (auto *memberTy = t->getAs<DependentMemberType>())
6289+
t = memberTy->getBase();
62916290

6292-
return false;
6291+
return t->is<TypeVariableType>();
62936292
}
62946293

62956294
inline bool TypeBase::isTypeParameter() {
6296-
if (is<GenericTypeParamType>())
6297-
return true;
6295+
Type t(this);
62986296

6299-
if (auto depMemTy = getAs<DependentMemberType>())
6300-
return depMemTy->getBase()->isTypeParameter();
6297+
while (auto *memberTy = t->getAs<DependentMemberType>())
6298+
t = memberTy->getBase();
6299+
6300+
return t->is<GenericTypeParamType>();
6301+
}
63016302

63026303
return false;
63036304
}

0 commit comments

Comments
 (0)