-
Notifications
You must be signed in to change notification settings - Fork 276
wrong inference of function literals off subclass-of types #2428
Description
I think our inference of singleton function or bound-method types when accessed off nominal-instance or subclass-of types is simply wrong and needs to be fixed. The nominal-instance type
Aincludes instances ofAand all subclasses ofA. That means it is wrong to say thatinstance_of_a.methodis a singleton bound-method type, unless eitherAorA.methodis marked as final. Similarly,type[A]includes subclasses ofA, sosubclass_of_A.methodcannot be a singleton function literal type.Accessing methods as attributes of class-literal types can still correctly return a function literal.
One unfortunate side effect of making the above fix is that we will lose go-to-definition on most methods. To avoid this regression, we may need to allow callable types to optionally carry a "most precise known" source definition (or definitions?), which is not "part of the type" in terms of type relations but can be used for go-to-definition.