Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Fix member access on generic classes #6418
The fix is straightforward, I just add/propagate the bound type variable values by mapping to supertype.
I didn't find any corner cases with class methods, and essentially follow the same logic as when we generate the callable from
For class attributes there are two things I fixed. First we used to prohibit ambiguous access:
class C(Generic[T]): x: T C.x # Error! C[int].x # Error!
but the type variables were leaking after an error, now they are erased to
class C(Generic[T]): x: T def get(cls) -> T: return cls.x # OK
(I also added a bunch of more detailed comments in this part of code.)