Skip to content

Commit 96a1ffd

Browse files
committed
moretests
1 parent 8d64cac commit 96a1ffd

File tree

1 file changed

+60
-15
lines changed

1 file changed

+60
-15
lines changed

toolchain/check/testdata/facet/access.carbon

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

83+
// --- fail_todo_convert_from_period_self_to_full_facet_value.carbon
84+
library "[[@TEST_NAME]]";
85+
86+
interface I {
87+
let I1:! type;
88+
}
89+
90+
fn F(U:! I where .I1 = .Self) {
91+
// CHECK:STDERR: fail_todo_convert_from_period_self_to_full_facet_value.carbon:[[@LINE+4]]:3: error: cannot convert type `U` that implements `I where .(I.I1) = .Self` into type implementing `I where .(I.I1) = U` [ConversionFailureFacetToFacet]
92+
// CHECK:STDERR: U as (I where .I1 = U);
93+
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~
94+
// CHECK:STDERR:
95+
U as (I where .I1 = U);
96+
// CHECK:STDERR: fail_todo_convert_from_period_self_to_full_facet_value.carbon:[[@LINE+4]]:3: error: cannot convert type `U` into type implementing `I where .(I.I1) = U` [ConversionFailureTypeToFacet]
97+
// CHECK:STDERR: (U as type) as (I where .I1 = U);
98+
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
99+
// CHECK:STDERR:
100+
(U as type) as (I where .I1 = U);
101+
}
102+
83103
// --- fail_todo_access_through_call.carbon
84104
library "[[@TEST_NAME]]";
85105

@@ -88,25 +108,49 @@ interface I {
88108
fn G() -> X;
89109
}
90110

111+
fn F2[U:! I](T: U) {}
112+
fn F3[U:! I where .X = .Self](T: U) {}
113+
91114
fn F(U:! I where .X = .Self) {
115+
// The returned value of `G` type `U` which has access to the methods of `I`.
116+
//
117+
// TODO: This works but a chained third call doesn't.
92118
U.G().G();
93-
94-
// TODO: This should typecheck.
95119
// - The first `.` is on a NameRef of type FacetType for `I where .X = .Self`.
96120
// - This finds `G` through the FacetType.
97121
// - The second `.` is on a Call of type FacetAccessType into `BindSymbolicName` with type FacetType for `I`.
98122
// - 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`
123+
// - The third `.` is on a Call of type FacetAccessType into `ImplWitnessAccess` of `I.X` into `LookupImplWitness`, which has type `type`
100124
// - Can't make calls on an `ImplWitnessAccess`.
101-
//
125+
// - We could expect that the constant value of the `ImplWitnessAccess` would
126+
// be the same type that we got for the second lookup.
102127
// CHECK:STDERR: fail_todo_access_through_call.carbon:[[@LINE+4]]:3: error: type `.(I.X)` does not support qualified expressions [QualifiedExprUnsupported]
103128
// CHECK:STDERR: U.G().G().G();
104129
// CHECK:STDERR: ^~~~~~~~~~~
105130
// CHECK:STDERR:
106131
U.G().G().G();
132+
// CHECK:STDERR: fail_todo_access_through_call.carbon:[[@LINE+4]]:3: error: type `.(I.X)` does not support qualified expressions [QualifiedExprUnsupported]
133+
// CHECK:STDERR: (U as type).G().G().G();
134+
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~
135+
// CHECK:STDERR:
136+
(U as type).G().G().G();
137+
138+
// The returned value of type `U` can be used as a value of type `U`.
139+
// CHECK:STDERR: fail_todo_access_through_call.carbon:[[@LINE+4]]:6: error: type `.(I.X)` does not support qualified expressions [QualifiedExprUnsupported]
140+
// CHECK:STDERR: F2(U.G().G().G());
141+
// CHECK:STDERR: ^~~~~~~~~~~
142+
// CHECK:STDERR:
143+
F2(U.G().G().G());
144+
145+
// TODO: The constraints in the type `U` are preserved.
146+
// CHECK:STDERR: fail_todo_access_through_call.carbon:[[@LINE+4]]:6: error: type `.(I.X)` does not support qualified expressions [QualifiedExprUnsupported]
147+
// CHECK:STDERR: F3(U.G().G().G());
148+
// CHECK:STDERR: ^~~~~~~~~~~
149+
// CHECK:STDERR:
150+
F3(U.G().G().G());
107151
}
108152

109-
// --- fail_todo_access_through_call_converts_is_a_type.carbon
153+
// --- fail_todo_compound_access_through_call.carbon
110154
library "[[@TEST_NAME]]";
111155

112156
interface I {
@@ -115,18 +159,19 @@ interface I {
115159
}
116160

117161
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.
162+
// TODO: The return of `I.G()` is a value with type `U` which is constrained
163+
// by `I`. We have access to the methods of `I` through name lookup, but how
164+
// do we get to them with compound member access?
165+
// See: https://github.com/carbon-language/carbon-lang/issues/6025
121166
//
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: ^~~~~~~~~~~~~
167+
// CHECK:STDERR: fail_todo_compound_access_through_call.carbon:[[@LINE+7]]:3: error: cannot implicitly convert non-type value of type `.Self` into type implementing `I` [ConversionFailureNonTypeToFacet]
168+
// CHECK:STDERR: U.(I.G)().(I.G)().(I.G)();
169+
// CHECK:STDERR: ^~~~~~~~~~~~~~~
170+
// CHECK:STDERR: fail_todo_compound_access_through_call.carbon:[[@LINE+4]]:3: note: type `.Self` does not implement interface `Core.ImplicitAs(I)` [MissingImplInMemberAccessNote]
171+
// CHECK:STDERR: U.(I.G)().(I.G)().(I.G)();
172+
// CHECK:STDERR: ^~~~~~~~~~~~~~~
128173
// CHECK:STDERR:
129-
U.G() as type;
174+
U.(I.G)().(I.G)().(I.G)();
130175
}
131176

132177
// --- fail_non_const_associated.carbon

0 commit comments

Comments
 (0)