mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-06 08:34:43 +01:00
Distinguish between the symbolic .Self value for an associated constant and the value found when referencing one. (#2348)
Within the type of an associated constant, references to `.Self` should resolve symbolically to that associated constant as a `GenericBinding` so that it can be substituted for the actual value when using its type. However, when the associated constant is referenced from elsewhere in the same interface, the value we want is a symbolic value naming the constant as a member of `Self`.
This commit is contained in:
@@ -18,7 +18,7 @@ interface Z {
|
||||
// We reject this even though it is the responsibility of the `impl as Z` to
|
||||
// provide a type `N` such that `i32 is X(N)`. We might want to treat this as
|
||||
// an implied constraint and allow this in the future.
|
||||
// CHECK:STDERR: COMPILATION ERROR: {{.*}}/explorer/testdata/assoc_const/fail_implied_constraints.carbon:[[@LINE+1]]: could not find implementation of interface X(T = (Self).(Z.N)) for i32
|
||||
// CHECK:STDERR: COMPILATION ERROR: {{.*}}/explorer/testdata/assoc_const/fail_implied_constraints.carbon:[[@LINE+1]]: could not find implementation of interface X(T = N) for i32
|
||||
let N:! Y(.Self) where .M = i32;
|
||||
}
|
||||
|
||||
|
||||
+3
-6
@@ -3,8 +3,9 @@
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
// AUTOUPDATE
|
||||
// RUN: %{not} %{explorer-run}
|
||||
// RUN: %{not} %{explorer-run-trace}
|
||||
// RUN: %{explorer-run}
|
||||
// RUN: %{explorer-run-trace}
|
||||
// CHECK:STDOUT: result: 0
|
||||
|
||||
package ExplorerTest api;
|
||||
|
||||
@@ -22,10 +23,6 @@ interface Z {
|
||||
|
||||
impl i32 as X(i32) {}
|
||||
impl i32 as Y(i32) where .M = i32 {}
|
||||
// TODO: This testcase should be accepted, but is currently not because the
|
||||
// rewrite for `.N` is not properly applied to impl constraints within the type
|
||||
// of N.
|
||||
// CHECK:STDERR: COMPILATION ERROR: {{.*}}/explorer/testdata/assoc_const/fail_impl_used_by_later_rewrite.carbon:[[@LINE+1]]: could not find implementation of interface Y(T = (.Self).(Z.N)) for i32
|
||||
impl i32 as Z where .N = i32 {}
|
||||
|
||||
fn F[A:! Z](a: A) -> A { return a; }
|
||||
Reference in New Issue
Block a user