Type check an expression of form '[...] * e'. Type inference is special-cased for this common construct.
(self, e: OpExpr)
| 4444 | return make_simplified_union([restricted_left_type, right_type]) |
| 4445 | |
| 4446 | def check_list_multiply(self, e: OpExpr) -> Type: |
| 4447 | """Type check an expression of form '[...] * e'. |
| 4448 | |
| 4449 | Type inference is special-cased for this common construct. |
| 4450 | """ |
| 4451 | right_type = self.accept(e.right) |
| 4452 | if is_subtype(right_type, self.named_type("builtins.int")): |
| 4453 | # Special case: [...] * <int value>. Use the type context of the |
| 4454 | # OpExpr, since the multiplication does not affect the type. |
| 4455 | left_type = self.accept(e.left, type_context=self.type_context[-1]) |
| 4456 | else: |
| 4457 | left_type = self.accept(e.left) |
| 4458 | result, method_type = self.check_op("__mul__", left_type, e.right, e) |
| 4459 | e.method_type = method_type |
| 4460 | return result |
| 4461 | |
| 4462 | def visit_assignment_expr(self, e: AssignmentExpr) -> Type: |
| 4463 | value = self.accept(e.value) |
no test coverage detected