Skip to content

Commit a2346db

Browse files
committed
[ConstraintSystem] Add a getAsTypeRepr helper method for casting ASTNodes.
1 parent b8ce899 commit a2346db

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

include/swift/Sema/ConstraintSystem.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,13 @@ template <typename T = Decl> T *getAsDecl(ASTNode node) {
680680
return nullptr;
681681
}
682682

683+
template <typename T = TypeRepr>
684+
T *getAsTypeRepr(ASTNode node) {
685+
if (auto *type = node.dyn_cast<TypeRepr *>())
686+
return dyn_cast_or_null<T>(type);
687+
return nullptr;
688+
}
689+
683690
template <typename T = Stmt>
684691
T *getAsStmt(ASTNode node) {
685692
if (auto *S = node.dyn_cast<Stmt *>())

0 commit comments

Comments
 (0)