Report an error if an override changes signature in unsupported ways. Glue methods can work around many signature changes but not all of them.
(
builder: IRBuilder, base_sig: FuncSignature, sub_sig: FuncSignature, line: int
)
| 777 | |
| 778 | |
| 779 | def check_native_override( |
| 780 | builder: IRBuilder, base_sig: FuncSignature, sub_sig: FuncSignature, line: int |
| 781 | ) -> None: |
| 782 | """Report an error if an override changes signature in unsupported ways. |
| 783 | |
| 784 | Glue methods can work around many signature changes but not all of them. |
| 785 | """ |
| 786 | for base_arg, sub_arg in zip(base_sig.real_args(), sub_sig.real_args()): |
| 787 | if base_arg.type.error_overlap: |
| 788 | if not base_arg.optional and sub_arg.optional and base_sig.num_bitmap_args: |
| 789 | # This would change the meanings of bits in the argument defaults |
| 790 | # bitmap, which we don't support. We'd need to do tricky bit |
| 791 | # manipulations to support this generally. |
| 792 | builder.error( |
| 793 | "An argument with type " |
| 794 | + f'"{base_arg.type}" cannot be given a default value in a method override', |
| 795 | line, |
| 796 | ) |
| 797 | if base_arg.type.error_overlap or sub_arg.type.error_overlap: |
| 798 | if not is_same_type(base_arg.type, sub_arg.type): |
| 799 | # This would change from signaling a default via an error value to |
| 800 | # signaling a default via bitmap, which we don't support. |
| 801 | builder.error( |
| 802 | "Incompatible argument type " |
| 803 | + f'"{sub_arg.type}" (base class has type "{base_arg.type}")', |
| 804 | line, |
| 805 | ) |
| 806 | |
| 807 | |
| 808 | def gen_glue_property( |
no test coverage detected
searching dependent graphs…