{{ message }}
Type inference: Generalize typeConstraintBaseTypeMatch#22052
Open
hvitved wants to merge 2 commits into
Open
Conversation
4909d80 to
36724d8
Compare
36724d8 to
8cfb152
Compare
Contributor
Author
typeConstraintBaseTypeMatchtypeConstraintBaseTypeMatch
Contributor
There was a problem hiding this comment.
Pull request overview
This PR generalizes typeConstraintBaseTypeMatch to reuse the existing typeMatch infrastructure, enabling more general type inference through constraints. It also adds a Rust regression test demonstrating the newly inferred types and updates a consistency expected file to reflect shifted line numbers.
Changes:
- Refactor type-constraint-based inference to use
typeMatchmore broadly (and adjust related access/constraint plumbing). - Add a Rust test case covering inference through a chained trait constraint (
MyTrait2<T2>whereT2: MyTrait<T1>). - Update the Rust path-resolution consistency expected output to match new source locations.
Show a summary per file
Review details
- Files reviewed: 3/4 changed files
- Comments generated: 2
- Review effort level: Low
8cfb152 to
bfc37e5
Compare
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.

The logic in
typeConstraintBaseTypeMatchwas previously hard-coded to only look at type parameters that could be directly matched via the type of an argument, but it is both more general and clean to use thetypeMatchpredicate (to whichtypeConstraintBaseTypeMatchalso itself contributes). I have added a test case that shows how this allows us to infer more types.DCA is uneventful, except there is an increase in
Nodes With Type At Length Limitforrendiation, but that will be fixed once #21795 is merged (this PR was extracted from that PR).