Skip to content

Consider using top / bottom materialization for assignability check #666

@dhruvmanila

Description

@dhruvmanila

The concept of top and bottom materialization of a type was added in astral-sh/ruff#18594.

@carljm mentioned that this could potentially be used to perform assignability, especially when gradual types are involved. Formally, if we want to check whether T is assignable to U, then we could check whether T', the bottom materialization (or lower bound materialization) of T, is a subtype of U', the top materialization (or upper bound materialization) of U.

The main benefit here is that this would eliminate any special handling of gradual types in the subtyping check and could eliminate any potential bugs that might exists in the current assignability implementation.

This issue is to keep track of this potential change if we decide to do it.

This would still require fulfilling the TODOs that are currently present in the implementation of type materialization in Type::materialize.

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-designNeeds further design before implementationtype propertiessubtyping, assignability, equivalence, and more

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions