[red-knot] Add MRO resolution for classes (#14027)

This commit is contained in:
Alex Waygood
2024-11-04 13:31:38 +00:00
committed by GitHub
parent 88d9bb191b
commit df45a0e3f9
13 changed files with 1175 additions and 124 deletions

View File

@@ -202,11 +202,7 @@ reveal_type(A() + B()) # revealed: MyString
# N.B. Still a subtype of `A`, even though `A` does not appear directly in the class's `__bases__`
class C(B): ...
# TODO: we currently only understand direct subclasses as subtypes of the superclass.
# We need to iterate through the full MRO rather than just the class's bases;
# if we do, we'll understand `C` as a subtype of `A`, and correctly understand this as being
# `MyString` rather than `str`
reveal_type(A() + C()) # revealed: str
reveal_type(A() + C()) # revealed: MyString
```
## Reflected precedence 2