-
Notifications
You must be signed in to change notification settings - Fork 135
Open
Labels
attribute accessInstance attributes, class attributes, etc.Instance attributes, class attributes, etc.bugSomething isn't workingSomething isn't workinggenericsBugs or features relating to ty's generics implementationBugs or features relating to ty's generics implementation
Milestone
Description
Consider the following example. ty currently emits two errors for the t.method() call because t.method creates a union of bound method objects where C.method and D.method are bound to T@f, respectively. Instead, attribute access should properly distribute across the union C | D and yield a union of bound method objects where C.method is bound to an instance of C, and D.method is bound to an instance of D:
class C:
def method(self) -> int:
return 0
class D:
def method(self) -> str:
return ""
def f[T: (C, D)](t: T):
# Argument to bound method `method` is incorrect: Expected `C`, found `T@f` (invalid-argument-type)
# Argument to bound method `method` is incorrect: Expected `D`, found `T@f` (invalid-argument-type)
reveal_type(t.method())https://play.ty.dev/c102d2bd-de4d-497c-9144-9f45def4196a
Related: #138
Metadata
Metadata
Assignees
Labels
attribute accessInstance attributes, class attributes, etc.Instance attributes, class attributes, etc.bugSomething isn't workingSomething isn't workinggenericsBugs or features relating to ty's generics implementationBugs or features relating to ty's generics implementation