Skip to content

Improve type inference for recursive protocols #3829

Description

@ilevkivskyi

Consider this example:

classP(Protocol[T_co]):
defmeth(self) ->P[T_co]: ...
classC(Generic[T]):
defmeth(self) ->C[T]: ...
deffun(arg: P[T]) ->T: ...
x: C[int]
reveal_type(f(x)) # I think this should be 'int'

But currently the inferred type is UninhabitedType, since we don't find any constraints for T due to a purely structural inference cycle. Unfortunately, it looks like this doesn't have simple solutions.

This is a follow-up for #3132

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions