Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR adds support for polymorphic (generic) functions in Thrust's refinement type system. The implementation introduces a deferred type checking mechanism where polymorphic functions without full annotations are analyzed on-demand when called with specific type arguments.
- Introduces
TypeArgsvsRefinedTypeArgsdistinction to separate unrefined type arguments from refined ones - Implements deferred type checking with caching for polymorphic function instantiations
- Adds
ParamTypeMapperto allow mapping type parameters during template generation - Adds comprehensive test coverage with pass/fail test pairs for various polymorphic scenarios
Reviewed Changes
Copilot reviewed 42 out of 42 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
src/rty/params.rs |
Introduces TypeArgs type alias and separate From implementations for TypeArgs and RefinedTypeArgs |
src/rty.rs |
Adds PartialEq, Eq, Hash derives to enable caching, updates signatures to use RefinedTypeArgs |
src/refine/template.rs |
Adds ParamTypeMapper trait and with_param_mapper method to support type parameter substitution during template generation |
src/analyze/local_def.rs |
Moves annotation extraction and expected_ty logic from crate analyzer to local def analyzer |
src/analyze/crate_.rs |
Refactors to use local def analyzer methods, adds logic to defer polymorphic function checking |
src/analyze/basic_block.rs |
Updates to use stored type_builder and def_ty_with_args for generic function calls |
src/analyze.rs |
Introduces DefTy enum with Concrete and Deferred variants, implements on-demand type checking with caching |
src/chc.rs |
Adds PartialEq, Eq, Hash derives to support type caching |
tests/ui/pass/*.rs |
Adds 16 passing test cases covering polymorphic functions with various features |
tests/ui/fail/*.rs |
Adds 16 failing test cases as counterparts to validate error detection |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
coeff-aij
pushed a commit
to coeff-aij/thrust
that referenced
this pull request
Jan 12, 2026
Support polymorphic functions
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.
Uh oh!
There was an error while loading. Please reload this page.