Skip to content

resolve typevar as Never instead of Unknown when it can't be resolved an is in union when appears in generic function call #1137

@KotlinIsland

Description

@KotlinIsland

Describe the Bug

from __future__  import annotations

class A[T]:
    def __init__(self, value: T) -> None:
        self.t: T = value
    def f[Expected](self) -> A[Expected | T]:
        return 

_: A[object] = A(1).f()  # no error, great

b = A(1).f()
b  # A[int | Unknown]

i would expect b to be A[int]

additionally, if we add a default of Never to Expected, then the Unknown still doensn't go away

Sandbox Link

No response

(Only applicable for extension issues) IDE Information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions