Calculate what information we can learn from the truth of (e1 or e2) in terms of the information that we can learn from the truth of e1 and the truth of e2. If coalesce_any is True, consider Any a supertype when joining restrictions.
(m1: TypeMap, m2: TypeMap, *, coalesce_any: bool = False)
| 8856 | |
| 8857 | |
| 8858 | def or_conditional_maps(m1: TypeMap, m2: TypeMap, *, coalesce_any: bool = False) -> TypeMap: |
| 8859 | """Calculate what information we can learn from the truth of (e1 or e2) |
| 8860 | in terms of the information that we can learn from the truth of e1 and |
| 8861 | the truth of e2. If coalesce_any is True, consider Any a supertype when |
| 8862 | joining restrictions. |
| 8863 | """ |
| 8864 | |
| 8865 | if is_unreachable_map(m1): |
| 8866 | return m2 |
| 8867 | if is_unreachable_map(m2): |
| 8868 | return m1 |
| 8869 | # Both conditions can be true. Combine information about |
| 8870 | # expressions whose type is refined by both conditions. (We do not |
| 8871 | # learn anything about expressions whose type is refined by only |
| 8872 | # one condition.) |
| 8873 | result: dict[Expression, Type] = {} |
| 8874 | for n1 in m1: |
| 8875 | for n2 in m2: |
| 8876 | if literal_hash(n1) == literal_hash(n2): |
| 8877 | if coalesce_any and isinstance(get_proper_type(m1[n1]), AnyType): |
| 8878 | result[n1] = m1[n1] |
| 8879 | else: |
| 8880 | result[n1] = make_simplified_union([m1[n1], m2[n2]]) |
| 8881 | return result |
| 8882 | |
| 8883 | |
| 8884 | def reduce_conditional_maps( |
no test coverage detected
searching dependent graphs…