Skip to content

Commit 8d64cac

Browse files
committed
test-call-returning-facet-value
1 parent 70f104a commit 8d64cac

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

toolchain/check/testdata/facet/access.carbon

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,55 @@ fn UseIndirect[T:! I](x: T) -> T {
8080
//@dump-sem-ir-end
8181
}
8282

83+
// --- fail_todo_access_through_call.carbon
84+
library "[[@TEST_NAME]]";
85+
86+
interface I {
87+
let X:! type;
88+
fn G() -> X;
89+
}
90+
91+
fn F(U:! I where .X = .Self) {
92+
U.G().G();
93+
94+
// TODO: This should typecheck.
95+
// - The first `.` is on a NameRef of type FacetType for `I where .X = .Self`.
96+
// - This finds `G` through the FacetType.
97+
// - The second `.` is on a Call of type FacetAccessType into `BindSymbolicName` with type FacetType for `I`.
98+
// - This finds `G` through the FacetType (impl lookup strips off FacetAccessType).
99+
// - The second `.` is on a Call of type FacetAccessType into `ImplWitnessAccess` of `I.X` into `LookupImplWitness`, which has type `type`
100+
// - Can't make calls on an `ImplWitnessAccess`.
101+
//
102+
// CHECK:STDERR: fail_todo_access_through_call.carbon:[[@LINE+4]]:3: error: type `.(I.X)` does not support qualified expressions [QualifiedExprUnsupported]
103+
// CHECK:STDERR: U.G().G().G();
104+
// CHECK:STDERR: ^~~~~~~~~~~
105+
// CHECK:STDERR:
106+
U.G().G().G();
107+
}
108+
109+
// --- fail_todo_access_through_call_converts_is_a_type.carbon
110+
library "[[@TEST_NAME]]";
111+
112+
interface I {
113+
let X:! type;
114+
fn G() -> X;
115+
}
116+
117+
fn F(U:! I where .X = .Self) {
118+
// TODO: The return type of G() is a FacetAccessType of a BindSymbolicName. We
119+
// try to convert a Call of type FacetAccessType (of type `type`) to `type`
120+
// which fails.
121+
//
122+
// CHECK:STDERR: fail_todo_access_through_call_converts_is_a_type.carbon:[[@LINE+7]]:3: error: cannot convert non-type value of type `.Self` to `type` with `as` [ConversionFailureNonTypeToFacet]
123+
// CHECK:STDERR: U.G() as type;
124+
// CHECK:STDERR: ^~~~~~~~~~~~~
125+
// CHECK:STDERR: fail_todo_access_through_call_converts_is_a_type.carbon:[[@LINE+4]]:3: note: type `.Self` does not implement interface `Core.As(type)` [MissingImplInMemberAccessNote]
126+
// CHECK:STDERR: U.G() as type;
127+
// CHECK:STDERR: ^~~~~~~~~~~~~
128+
// CHECK:STDERR:
129+
U.G() as type;
130+
}
131+
83132
// --- fail_non_const_associated.carbon
84133
library "[[@TEST_NAME]]";
85134

0 commit comments

Comments
 (0)