Skip to content

Should top_materialization use default_specialization for type vars? #1164

@sharkdp

Description

@sharkdp

@AlexWaygood:

I wondered if class.top_materialization() would work here, but it looks like under the hood that uses default_specialization(), so it suffers from the same issue as our current logic on main. (It probably shouldn't use default_specialization()?)

@dcreager

I think you're right — it should translate typevars into the bound/constraints in covariant position, and to Never (the implicit lower bound of every typevar) in contravariant position. (With the caveat that we can't really express the constraints of a constrained typevar as a single type — we'd need a "one-of" connective instead of union, and an "instance of this type but not any subtypes".)

Originally posted by @AlexWaygood in astral-sh/ruff#20325 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    type propertiessubtyping, assignability, equivalence, and more

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions