Skip to content

Protocol seems to only match the first overload #6549

Answered by erictraut
twoertwein asked this question in Q&A
Discussion options

You must be logged in to vote

I agree this is an abuse of the type system, and I don't recommend you use this approach. You're in very iffy and indeterminate areas of the type system.

The constraint solver, when solving for the TypeVar _Other in the add protocol must arbitrarily choose from either the first or second overload since both of them match the add.__add__ method. Choosing the first one seems like a logical choice, since that mirrors the general overload matching behavior for calls.

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@twoertwein
Comment options

@twoertwein
Comment options

Answer selected by twoertwein
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants