Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix infinite recursion in recursive-typedef subtype check
Recursive typedefs are not supposed to be possible, but there's a way to create them using forward-referenced named types. If such a recursive type is checked against a separate-but-equivalent @record or @typedef type, the type checker currently blows up with infinite recursion. This can be prevented by taking advantage of the ImplCache in PrototypeObjectType#isSubtype. Doing this correctly requires carefully threading the needle through the various special cases and overrides of isSubtype, particularly due to a separate structural-subtype check that sometimes runs in addition to the version in PrototypeObjectType - if it reports (and caches) a different result then we end up with problems in union coalescing (either under- or over-collapsing), missing property detection, or various other places. This CL attempts to consolidate the two structural checks into one by adding some extra dimensions to the check: (1) whether the supertype is an inline record literal or not (to determines which properties to match) and (2) whether to require explicitly voidable supertype props to be present in the subtype. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=232600301
- Loading branch information
Showing
6 changed files
with
255 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.