forked from carbon-language/carbon-lang
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deduce facet values for arguments to generic fns receiving a facet ty…
…pe (carbon-language#4865) The fn receiving a facet type needs to deduce a type from a FacetAccessType, which is the SemIR type representing the parameter type that is a generic parameter. For example: ``` fn F[T: Interface](val: T); ``` Here T is a generic parameter that is a facet value, but the `val` parameter's type is the facet value converted from a FacetType to a TypeType, with `as type`. The result of that conversion is a FacetAccessType. So the deduction code sees a FacetAccessType for the type of `val`. We make deduction undo the `as type` conversion to move back to the `T` parameter declaration, which has type FacetType in order to deduce the required facet value (which is itself a type constrained by the FacetType). And when we have a facet value (of type FacetType) to be deduced, we will also convert the argument if it is of an appropriate type to a FacetValue that matches the FacetType using the changes from PR carbon-language#4863. Tests with `impl forall` can cause impl deduction to recurse forever and crash, so those tests are omitted in this PR and they will come in follow-up work that address the infinite recursion. Rebased on top of PR carbon-language#4885
- Loading branch information
Showing
8 changed files
with
2,347 additions
and
154 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
586 changes: 486 additions & 100 deletions
586
.../testdata/builtin_conversions/no_prelude/convert_class_type_to_generic_facet_value.carbon
Large diffs are not rendered by default.
Oops, something went wrong.
264 changes: 264 additions & 0 deletions
264
...k/testdata/builtin_conversions/no_prelude/convert_class_value_to_facet_value_value.carbon
Large diffs are not rendered by default.
Oops, something went wrong.
460 changes: 460 additions & 0 deletions
460
...ta/builtin_conversions/no_prelude/convert_class_value_to_generic_facet_value_value.carbon
Large diffs are not rendered by default.
Oops, something went wrong.
303 changes: 253 additions & 50 deletions
303
...stdata/builtin_conversions/no_prelude/fail_todo_convert_facet_value_to_facet_value.carbon
Large diffs are not rendered by default.
Oops, something went wrong.
253 changes: 253 additions & 0 deletions
253
...uiltin_conversions/no_prelude/fail_todo_convert_facet_value_to_narrowed_facet_type.carbon
Large diffs are not rendered by default.
Oops, something went wrong.
601 changes: 601 additions & 0 deletions
601
...rsions/no_prelude/fail_todo_convert_facet_value_value_to_generic_facet_value_value.carbon
Large diffs are not rendered by default.
Oops, something went wrong.