Fix crash overriding partial-type attribute with method #12943
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Attributes can still be partially typed (e.g.
<partial list[?]>
) aftera parent-class definition if the block they are declared in is deferred.
The first pass for child classes might then encounter this type when
considering method overrides, which could cause a crash when attempting
to determine subtype compatibility.
This patch causes the subtype checker to defer the override test if the original type is still partial, avoiding the crash. The correct error messages are still reported after this. This is the same approach as suggested by #11686 (comment), but the test case is different to the original issue. The original reproducer involved
@property
, which runs afoul of #4125, and a full fix there is likely better part of #7724. The behaviour is not caused by@property
itself, though, but any method overriding a value with partially inferred type.Fixes #11686
Fixes #11981
Test Plan
Added test case to
check-classes.test
.