(t: CallableType, s: CallableType)
| 745 | |
| 746 | |
| 747 | def match_generic_callables(t: CallableType, s: CallableType) -> tuple[CallableType, CallableType]: |
| 748 | # The case where we combine/join/meet similar callables, situation where both are generic |
| 749 | # requires special care. A more principled solution may involve unify_generic_callable(), |
| 750 | # but it would have two problems: |
| 751 | # * This adds risk of infinite recursion: e.g. join -> unification -> solver -> join |
| 752 | # * Using unification is an incorrect thing for meets, as it "widens" the types |
| 753 | # Finally, this effectively falls back to an old behaviour before namespaces were added to |
| 754 | # type variables, and it worked relatively well. |
| 755 | max_len = max(len(t.variables), len(s.variables)) |
| 756 | min_len = min(len(t.variables), len(s.variables)) |
| 757 | if min_len == 0: |
| 758 | return t, s |
| 759 | new_ids = [TypeVarId.new(meta_level=0) for _ in range(max_len)] |
| 760 | # Note: this relies on variables being in order they appear in function definition. |
| 761 | return update_callable_ids(t, new_ids), update_callable_ids(s, new_ids) |
| 762 | |
| 763 | |
| 764 | def join_similar_callables(t: CallableType, s: CallableType) -> CallableType: |
no test coverage detected
searching dependent graphs…