Add facet type values and an instruction that produces them (#4460)

Still to do:
* Represent facet type values in a canonical form
* Produce & consume facet type values instead of interface values
* `type` should be associated with a canonical facet type value
* Support `&` on facet type values
* Type check and enforce requirements in facet types

---------

Co-authored-by: Josh L <josh11b@users.noreply.github.com>
This commit is contained in:
josh11b
2024-11-04 21:43:55 +00:00
committed by GitHub
co-authored by Josh L
parent 607522c7de
commit ea0b0b4b48
18 changed files with 495 additions and 253 deletions
@@ -10,7 +10,7 @@
interface I { let T:! type; }
// CHECK:STDERR: fail_todo_impl_assoc_const.carbon:[[@LINE+10]]:1: error: semantics TODO: `impl of interface with associated constant` [SemanticsTodo]
// CHECK:STDERR: fail_todo_impl_assoc_const.carbon:[[@LINE+10]]:1: error: semantics TODO: `impl as non-interface` [SemanticsTodo]
// CHECK:STDERR: impl bool as I where .T = bool {}
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR:
@@ -50,6 +50,7 @@ impl bool as I where .T = bool {}
// CHECK:STDOUT: %.6: type = assoc_entity_type %ImplicitAs.type.3, %Convert.type.2 [template]
// CHECK:STDOUT: %.7: %.6 = assoc_entity element0, imports.%import_ref.6 [template]
// CHECK:STDOUT: %.8: %.4 = assoc_entity element0, imports.%import_ref.7 [symbolic]
// CHECK:STDOUT: %.9: type = facet_type <facet-type %I.type+requirements> [template]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: imports {
@@ -90,7 +91,7 @@ impl bool as I where .T = bool {}
// CHECK:STDOUT: %.loc23_27.2: ref type = temporary_storage
// CHECK:STDOUT: %.loc23_27.3: ref type = temporary %.loc23_27.2, %bool.make_type.loc23_27
// CHECK:STDOUT: %.loc23_27.4: %.1 = converted %bool.make_type.loc23_27, <error> [template = <error>]
// CHECK:STDOUT: %.loc23_16: type = where_expr %.Self [template = constants.%I.type] {
// CHECK:STDOUT: %.loc23_16: type = where_expr %.Self [template = constants.%.9] {
// CHECK:STDOUT: requirement_rewrite %T.ref, <error>
// CHECK:STDOUT: }
// CHECK:STDOUT: }