mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-07 17:10:31 +00:00
![]() This fixes our logic for binding a legacy typevar with its binding context. (To recap, a legacy typevar starts out "unbound" when it is first created, and each time it's used in a generic class or function, we "bind" it with the corresponding `Definition`.) We treat `typing.Self` the same as a legacy typevar, and so we apply this binding logic to it too. Before, we were using the enclosing class as its binding context. But that's not correct — it's the method where `typing.Self` is used that binds the typevar. (Each invocation of the method will find a new specialization of `Self` based on the specific instance type containing the invoked method.) This required plumbing through some additional state to the `in_type_expression` method. This also revealed that we weren't handling `Self`-typed instance attributes correctly (but were coincidentally not getting the expected false positive diagnostics). |
||
---|---|---|
.. | ||
corpus | ||
mdtest | ||
primer | ||
README.md |
Markdown files within the mdtest/
subdirectory are tests of type inference and type checking;
executed by the tests/mdtest.rs
integration test.
See crates/ty_test/README.md
for documentation of this test format.