Type check calling a member expression where the base type is a union.
(self, e: CallExpr, object_type: UnionType, member: str)
| 1499 | return ret_type |
| 1500 | |
| 1501 | def check_union_call_expr(self, e: CallExpr, object_type: UnionType, member: str) -> Type: |
| 1502 | """Type check calling a member expression where the base type is a union.""" |
| 1503 | res: list[Type] = [] |
| 1504 | for typ in flatten_nested_unions(object_type.relevant_items()): |
| 1505 | # Member access errors are already reported when visiting the member expression. |
| 1506 | with self.msg.filter_errors(): |
| 1507 | item = analyze_member_access( |
| 1508 | member, |
| 1509 | typ, |
| 1510 | e, |
| 1511 | is_lvalue=False, |
| 1512 | is_super=False, |
| 1513 | is_operator=False, |
| 1514 | original_type=object_type, |
| 1515 | chk=self.chk, |
| 1516 | in_literal_context=self.is_literal_context(), |
| 1517 | self_type=typ, |
| 1518 | ) |
| 1519 | narrowed = self.narrow_type_from_binder(e.callee, item, skip_non_overlapping=True) |
| 1520 | if narrowed is None: |
| 1521 | continue |
| 1522 | callable_name = self.method_fullname(typ, member) |
| 1523 | item_object_type = typ if callable_name else None |
| 1524 | res.append( |
| 1525 | self.check_call_expr_with_callee_type(narrowed, e, callable_name, item_object_type) |
| 1526 | ) |
| 1527 | return make_simplified_union(res) |
| 1528 | |
| 1529 | def check_call( |
| 1530 | self, |
no test coverage detected