Skip to content

Conversation

@JelleZijlstra
Copy link
Member

Fixes #9451

Description

Previously, generic types were considered overlapping as soon as the first type argument matched. Now, we check all type arguments.

Test Plan

The new test failed before my change and now passes.

Copy link
Collaborator

@hauntsaninja hauntsaninja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

Comment on lines 339 to 341
# Or, to use a more concrete example, List[Union[A, B]] and List[Union[B, C]]
# would be considered partially overlapping since it's possible for both lists
# to contain only instances of B at runtime.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at this example I am wondering if the original behavior wasn't intentional?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The example only has a single type argument; I think the case with multiple args was just not considered.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I stumbled a little on this too, unions are dealt with by the recursive call, about a hundred lines earlier in the function

Copy link
Collaborator

@JukkaL JukkaL left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks this was an oversight in the original implementation.

@JelleZijlstra JelleZijlstra merged commit 44a9687 into python:master Sep 18, 2020
@JelleZijlstra JelleZijlstra deleted the overlap branch September 18, 2020 16:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Overload with Dict only checks overlap on keys

4 participants