Skip to content

Type inference should dynamically resolve typing.Self #602

@eb8680

Description

@eb8680

We'd like to be able to use typing.Self to annotate return types of method Operations. From the typing standard library documentation and the official typing specification, Self is equivalent to a type variable in the following sense, so it should be straightforward to fold into our existing machinery for handling type variables in internals.unification:

class Foo:
  def return_self[Self: "Foo"](self: Self) -> Self:
    ...
    return self

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions