ruff/crates/red_knot_python_semantic/resources/mdtest/generics
Douglas Creager ff376fc262
[red-knot] Allow explicit specialization of generic classes (#17023)
This PR lets you explicitly specialize a generic class using a subscript
expression. It introduces three new Rust types for representing classes:

- `NonGenericClass`
- `GenericClass` (not specialized)
- `GenericAlias` (specialized)

and two enum wrappers:

- `ClassType` (a non-generic class or generic alias, represents a class
_type_ at runtime)
- `ClassLiteralType` (a non-generic class or generic class, represents a
class body in the AST)

We also add internal support for specializing callables, in particular
function literals. (That is, the internal `Type` representation now
attaches an optional specialization to a function literal.) This is used
in this PR for the methods of a generic class, but should also give us
most of what we need for specializing generic _functions_ (which this PR
does not yet tackle).

---------

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Carl Meyer <carl@astral.sh>
2025-04-09 11:18:46 -04:00
..
classes.md [red-knot] Allow explicit specialization of generic classes (#17023) 2025-04-09 11:18:46 -04:00
functions.md [red-knot] Add Type::TypeVar variant (#17102) 2025-04-03 14:36:29 -04:00
legacy.md [red-knot] Several failing tests for generics (#16509) 2025-03-05 17:21:19 -05:00
pep695.md [red-knot] don't remove negations when simplifying constrained typevars (#17189) 2025-04-03 16:30:57 -07:00
scoping.md [red-knot] Allow explicit specialization of generic classes (#17023) 2025-04-09 11:18:46 -04:00