(&mut self, annotation: &ast::Expr)
| 7069 | } |
| 7070 | |
| 7071 | fn compile_annotation(&mut self, annotation: &ast::Expr) -> CompileResult<()> { |
| 7072 | if self.future_annotations { |
| 7073 | self.emit_load_const(ConstantData::Str { |
| 7074 | value: UnparseExpr::new(annotation, &self.source_file) |
| 7075 | .to_string() |
| 7076 | .into(), |
| 7077 | }); |
| 7078 | } else { |
| 7079 | let was_in_annotation = self.in_annotation; |
| 7080 | self.in_annotation = true; |
| 7081 | |
| 7082 | // Special handling for starred annotations (*Ts -> Unpack[Ts]) |
| 7083 | let result = match annotation { |
| 7084 | ast::Expr::Starred(ast::ExprStarred { value, .. }) => { |
| 7085 | // *args: *Ts (where Ts is a TypeVarTuple). |
| 7086 | // Do [annotation_value] = [*Ts]. |
| 7087 | self.compile_expression(value)?; |
| 7088 | emit!(self, Instruction::UnpackSequence { count: 1 }); |
| 7089 | Ok(()) |
| 7090 | } |
| 7091 | _ => self.compile_expression(annotation), |
| 7092 | }; |
| 7093 | |
| 7094 | self.in_annotation = was_in_annotation; |
| 7095 | result?; |
| 7096 | } |
| 7097 | Ok(()) |
| 7098 | } |
| 7099 | |
| 7100 | fn compile_annotated_assign( |
| 7101 | &mut self, |
no test coverage detected