summaryrefslogtreecommitdiffstats
path: root/Python/ast_opt.c
diff options
context:
space:
mode:
Diffstat (limited to 'Python/ast_opt.c')
-rw-r--r--Python/ast_opt.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/Python/ast_opt.c b/Python/ast_opt.c
index 3883ec9..c5b3e07 100644
--- a/Python/ast_opt.c
+++ b/Python/ast_opt.c
@@ -642,6 +642,7 @@ static int astfold_withitem(withitem_ty node_, PyArena *ctx_, _PyASTOptimizeStat
static int astfold_excepthandler(excepthandler_ty node_, PyArena *ctx_, _PyASTOptimizeState *state);
static int astfold_match_case(match_case_ty node_, PyArena *ctx_, _PyASTOptimizeState *state);
static int astfold_pattern(pattern_ty node_, PyArena *ctx_, _PyASTOptimizeState *state);
+static int astfold_typeparam(typeparam_ty node_, PyArena *ctx_, _PyASTOptimizeState *state);
#define CALL(FUNC, TYPE, ARG) \
if (!FUNC((ARG), ctx_, state)) \
@@ -880,6 +881,7 @@ astfold_stmt(stmt_ty node_, PyArena *ctx_, _PyASTOptimizeState *state)
}
switch (node_->kind) {
case FunctionDef_kind:
+ CALL_SEQ(astfold_typeparam, typeparam, node_->v.FunctionDef.typeparams);
CALL(astfold_arguments, arguments_ty, node_->v.FunctionDef.args);
CALL(astfold_body, asdl_seq, node_->v.FunctionDef.body);
CALL_SEQ(astfold_expr, expr, node_->v.FunctionDef.decorator_list);
@@ -888,6 +890,7 @@ astfold_stmt(stmt_ty node_, PyArena *ctx_, _PyASTOptimizeState *state)
}
break;
case AsyncFunctionDef_kind:
+ CALL_SEQ(astfold_typeparam, typeparam, node_->v.AsyncFunctionDef.typeparams);
CALL(astfold_arguments, arguments_ty, node_->v.AsyncFunctionDef.args);
CALL(astfold_body, asdl_seq, node_->v.AsyncFunctionDef.body);
CALL_SEQ(astfold_expr, expr, node_->v.AsyncFunctionDef.decorator_list);
@@ -896,6 +899,7 @@ astfold_stmt(stmt_ty node_, PyArena *ctx_, _PyASTOptimizeState *state)
}
break;
case ClassDef_kind:
+ CALL_SEQ(astfold_typeparam, typeparam, node_->v.ClassDef.typeparams);
CALL_SEQ(astfold_expr, expr, node_->v.ClassDef.bases);
CALL_SEQ(astfold_keyword, keyword, node_->v.ClassDef.keywords);
CALL(astfold_body, asdl_seq, node_->v.ClassDef.body);
@@ -922,6 +926,11 @@ astfold_stmt(stmt_ty node_, PyArena *ctx_, _PyASTOptimizeState *state)
}
CALL_OPT(astfold_expr, expr_ty, node_->v.AnnAssign.value);
break;
+ case TypeAlias_kind:
+ CALL(astfold_expr, expr_ty, node_->v.TypeAlias.name);
+ CALL_SEQ(astfold_typeparam, typeparam, node_->v.TypeAlias.typeparams);
+ CALL(astfold_expr, expr_ty, node_->v.TypeAlias.value);
+ break;
case For_kind:
CALL(astfold_expr, expr_ty, node_->v.For.target);
CALL(astfold_expr, expr_ty, node_->v.For.iter);
@@ -1074,6 +1083,21 @@ astfold_match_case(match_case_ty node_, PyArena *ctx_, _PyASTOptimizeState *stat
return 1;
}
+static int
+astfold_typeparam(typeparam_ty node_, PyArena *ctx_, _PyASTOptimizeState *state)
+{
+ switch (node_->kind) {
+ case TypeVar_kind:
+ CALL_OPT(astfold_expr, expr_ty, node_->v.TypeVar.bound);
+ break;
+ case ParamSpec_kind:
+ break;
+ case TypeVarTuple_kind:
+ break;
+ }
+ return 1;
+}
+
#undef CALL
#undef CALL_OPT
#undef CALL_SEQ