mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-06 06:34:41 +01:00
Track witnesses wherever possible (#2263)
Change explorer's handling of witnesses to track them wherever possible. Associated constant support needs witnesses to be available much more pervasively. The main changes here are: - `Substitute` now takes a set of bindings covering both `Value`s for `GenericBinding`s and `Witness`es for `ImplBinding`s, and substitutes both. - Witnesses are now tracked within `ConstraintType`s. The `.Self` type has an `ImplBinding` that self-references from parts of the constraint to other parts of the constraint can use to access the witness for the constraint. - The constraint type for an `impl` and for a `GenericBinding` are now stored in pre-substituted form, with references to the actual constrained type rather than symbolic references to `.Self`. This results in minor changes in diagnostic text. Argument deduction still performs substitutions without remapping witnesses.
This commit is contained in:
+1
-1
@@ -11,7 +11,7 @@ package ExplorerTest api;
|
||||
fn Bad[T:! Type](x: {.a: i32, .b: T}) {}
|
||||
|
||||
fn Main() -> i32 {
|
||||
// CHECK:COMPILATION ERROR: {{.*}}/explorer/testdata/generic_function/fail_implicit_conversion_extra_field.carbon:[[@LINE+1]]: mismatch in field names, source field `c` not in destination type `{.a: i32, .b: T:! Type}`
|
||||
// CHECK:COMPILATION ERROR: {{.*}}/explorer/testdata/generic_function/fail_implicit_conversion_extra_field.carbon:[[@LINE+1]]: mismatch in field names, source field `c` not in destination type `{.a: i32, .b: T}`
|
||||
Bad({.b = 5, .a = 7, .c = 2});
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ package ExplorerTest api;
|
||||
|
||||
fn id[T:! Type](x: T) -> T {
|
||||
// CHECK:COMPILATION ERROR: {{.*}}/explorer/testdata/generic_function/fail_not_addable.carbon:[[@LINE+2]]: type error in `+`:
|
||||
// CHECK:could not find implementation of interface AddWith(U = i32) for T:! Type
|
||||
// CHECK:could not find implementation of interface AddWith(U = i32) for T
|
||||
return x + 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user