You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: toolchain/check/testdata/facet/access.carbon
+96-12Lines changed: 96 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -100,6 +100,27 @@ fn F(U:! I where .I1 = .Self) {
100
100
(U astype) as (I where .I1= U);
101
101
}
102
102
103
+
// --- access_through_call_once.carbon
104
+
library "[[@TEST_NAME]]";
105
+
106
+
// TODO: Merge this test with the one below once it works.
107
+
108
+
interfaceI {
109
+
let X:!type;
110
+
fnG() -> X;
111
+
}
112
+
113
+
fnF2[U:! I](V: U) {}
114
+
115
+
fnF(U:! I where .X= .Self, V: U) {
116
+
// The returned value of `G` type `U` which has access to the methods of `I`.
117
+
U.G().G();
118
+
(U astype).G().G();
119
+
120
+
// The returned value of type `U` can be used as a value of type `U`.
121
+
F2(U.G());
122
+
}
123
+
103
124
// --- fail_todo_access_through_call.carbon
104
125
library "[[@TEST_NAME]]";
105
126
@@ -114,8 +135,7 @@ fn F3[U:! I where .X = .Self](V: U) {}
114
135
fnF(U:! I where .X= .Self, V: U) {
115
136
// The returned value of `G` type `U` which has access to the methods of `I`.
116
137
//
117
-
// TODO: This works but a chained third call doesn't.
118
-
U.G().G();
138
+
// TODO: These should work.
119
139
// - The first `.` is on a NameRef of type FacetType for `I where .X = .Self`.
120
140
// - This finds `G` through the FacetType.
121
141
// - The second `.` is on a Call of type FacetAccessType into `BindSymbolicName` with type FacetType for `I`.
@@ -129,8 +149,6 @@ fn F(U:! I where .X = .Self, V: U) {
129
149
// CHECK:STDERR: ^~~~~~~~~~~
130
150
// CHECK:STDERR:
131
151
U.G().G().G();
132
-
// TODO: This works but a chained third call doesn't.
133
-
(U astype).G().G();
134
152
// CHECK:STDERR: fail_todo_access_through_call.carbon:[[@LINE+4]]:3: error: type `.(I.X)` does not support qualified expressions [QualifiedExprUnsupported]
135
153
// CHECK:STDERR: (U as type).G().G().G();
136
154
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~
@@ -139,8 +157,7 @@ fn F(U:! I where .X = .Self, V: U) {
139
157
140
158
// The returned value of type `U` can be used as a value of type `U`.
141
159
//
142
-
// TODO: This works but a chaining calls to G doesn't.
143
-
F2(U.G());
160
+
// TODO: This should work.
144
161
// CHECK:STDERR: fail_todo_access_through_call.carbon:[[@LINE+4]]:6: error: type `.(I.X)` does not support qualified expressions [QualifiedExprUnsupported]
145
162
// CHECK:STDERR: F2(U.G().G().G());
146
163
// CHECK:STDERR: ^~~~~~~~~~~
@@ -153,7 +170,7 @@ fn F(U:! I where .X = .Self, V: U) {
153
170
// CHECK:STDERR: fail_todo_access_through_call.carbon:[[@LINE+7]]:3: error: cannot convert type `.Self` that implements `I` into type implementing `I where .(I.X) = .Self` [ConversionFailureFacetToFacet]
154
171
// CHECK:STDERR: F3(U.G());
155
172
// CHECK:STDERR: ^~~~~~~~~
156
-
// CHECK:STDERR: fail_todo_access_through_call.carbon:[[@LINE-44]]:1: note: while deducing parameters of generic declared here [DeductionGenericHere]
173
+
// CHECK:STDERR: fail_todo_access_through_call.carbon:[[@LINE-40]]:1: note: while deducing parameters of generic declared here [DeductionGenericHere]
157
174
// CHECK:STDERR: fn F3[U:! I where .X = .Self](V: U) {}
// CHECK:STDERR: fail_todo_compound_access_through_call.carbon:[[@LINE+7]]:14: error: cannot implicitly convert expression of type `.Self` to `U` [ConversionFailure]
202
+
// CHECK:STDERR: let u: U = U.(I.G)();
203
+
// CHECK:STDERR: ^~~~~~~~~
204
+
// CHECK:STDERR: fail_todo_compound_access_through_call.carbon:[[@LINE+4]]:14: note: type `.Self` does not implement interface `Core.ImplicitAs(U)` [MissingImplInMemberAccessNote]
205
+
// CHECK:STDERR: let u: U = U.(I.G)();
206
+
// CHECK:STDERR: ^~~~~~~~~
207
+
// CHECK:STDERR:
208
+
let u: U= U.(I.G)();
209
+
// `u` is a non-type value. Can call methods with `self` through compound
210
+
// member lookup, but can't call methods without `self`. See the
211
+
// `compound_access_through_call_with_self_param.carbon` test for the former.
212
+
//
213
+
// CHECK:STDERR: fail_todo_compound_access_through_call.carbon:[[@LINE+4]]:6: error: value of type `<associated entity in I>` is not callable [CallToNonCallable]
214
+
// CHECK:STDERR: u.(I.G());
215
+
// CHECK:STDERR: ^~~~~
216
+
// CHECK:STDERR:
217
+
u.(I.G());
218
+
219
+
// This is the same as the above, since G() returns a non-type value of type
220
+
// `U`.
180
221
//
181
-
// CHECK:STDERR: fail_compound_access_through_call.carbon:[[@LINE+7]]:3: error: cannot implicitly convert non-type value of type `.Self` into type implementing `I` [ConversionFailureNonTypeToFacet]
222
+
// 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]
182
223
// CHECK:STDERR: U.(I.G)().(I.G)();
183
224
// CHECK:STDERR: ^~~~~~~~~~~~~~~
184
-
// CHECK:STDERR: fail_compound_access_through_call.carbon:[[@LINE+4]]:3: note: type `.Self` does not implement interface `Core.ImplicitAs(I)` [MissingImplInMemberAccessNote]
225
+
// CHECK:STDERR: fail_todo_compound_access_through_call.carbon:[[@LINE+4]]:3: note: type `.Self` does not implement interface `Core.ImplicitAs(I)` [MissingImplInMemberAccessNote]
// Compound member lookup through a non-type value is possible for methods
242
+
// which take a `self` parameter.
243
+
244
+
// TODO: This should all work.
245
+
246
+
// CHECK:STDERR: fail_todo_compound_access_through_call_with_self_param.carbon:[[@LINE+4]]:14: error: cannot access member of interface `I` in type `I where .(I.X) = .Self` that does not implement that interface [MissingImplInMemberAccess]
247
+
// CHECK:STDERR: let u: U = U.(I.G)();
248
+
// CHECK:STDERR: ^~~~~~~
249
+
// CHECK:STDERR:
250
+
let u: U= U.(I.G)();
251
+
// `u` is a non-type value. Can call methods with `self` through compound
252
+
// member lookup, but can't call methods without `self`. See the
253
+
// `compound_access_through_call.carbon` test for the latter.
254
+
// CHECK:STDERR: fail_todo_compound_access_through_call_with_self_param.carbon:[[@LINE+4]]:6: error: member name `G2` not found in `I` [MemberNameNotFoundInInstScope]
255
+
// CHECK:STDERR: u.(I.G2());
256
+
// CHECK:STDERR: ^~~~
257
+
// CHECK:STDERR:
258
+
u.(I.G2());
259
+
260
+
// This is the same as the above, since G() returns a non-type value of type
261
+
// `U`.
262
+
//
263
+
// This works because G2 has a `self` parameter.
264
+
// CHECK:STDERR: fail_todo_compound_access_through_call_with_self_param.carbon:[[@LINE+8]]:3: error: cannot access member of interface `I` in type `I where .(I.X) = .Self` that does not implement that interface [MissingImplInMemberAccess]
265
+
// CHECK:STDERR: U.(I.G)().(I.G2)();
266
+
// CHECK:STDERR: ^~~~~~~
267
+
// CHECK:STDERR:
268
+
// CHECK:STDERR: fail_todo_compound_access_through_call_with_self_param.carbon:[[@LINE+4]]:14: error: member name `G2` not found in `I` [MemberNameNotFoundInInstScope]
// TODO: We should diagnose this use of `.Self` directly rather than later when
45
+
// it is converted to `type`.
44
46
interfaceI(T:! .Self) {
45
47
// CHECK:STDERR: fail_period_self_as_type.carbon:[[@LINE+7]]:13: error: cannot implicitly convert non-type value of type `.Self` to `type` [ConversionFailureNonTypeToFacet]
// CHECK:STDERR: fail_todo_return_of_period_self_impls_interface.carbon:[[@LINE+7]]:14: error: cannot implicitly convert expression of type `.Self` to `U` [ConversionFailure]
186
+
// CHECK:STDERR: let u: U = U.I1();
187
+
// CHECK:STDERR: ^~~~~~
188
+
// CHECK:STDERR: fail_todo_return_of_period_self_impls_interface.carbon:[[@LINE+4]]:14: note: type `.Self` does not implement interface `Core.ImplicitAs(U)` [MissingImplInMemberAccessNote]
189
+
// CHECK:STDERR: let u: U = U.I1();
190
+
// CHECK:STDERR: ^~~~~~
191
+
// CHECK:STDERR:
192
+
let u: U= U.I1();
193
+
// `u` is a non-type value. Can call methods with `self` through compound
194
+
// member lookup, but can't call methods without `self`. See the
195
+
// `compound_access_through_call_with_self_param.carbon` test for the former.
196
+
//
197
+
// CHECK:STDERR: fail_todo_return_of_period_self_impls_interface.carbon:[[@LINE+4]]:6: error: type `<type of J>` does not support qualified expressions [QualifiedExprUnsupported]
198
+
// CHECK:STDERR: u.(J.J1)();
199
+
// CHECK:STDERR: ^~~~
200
+
// CHECK:STDERR:
201
+
u.(J.J1)();
202
+
203
+
// This is the same as the above, since U.I1() returns a non-type value of
204
+
// type `U`.
179
205
//
180
-
// CHECK:STDERR: fail_return_of_period_self_impls_interface.carbon:[[@LINE+4]]:11: error: type `<type of J>` does not support qualified expressions [QualifiedExprUnsupported]
206
+
// CHECK:STDERR: fail_todo_return_of_period_self_impls_interface.carbon:[[@LINE+4]]:11: error: type `<type of J>` does not support qualified expressions [QualifiedExprUnsupported]
181
207
// CHECK:STDERR: U.I1().(J.J1)();
182
208
// CHECK:STDERR: ^~~~
183
209
// CHECK:STDERR:
@@ -221,19 +247,6 @@ fn F(U:! I where .X = .Self) {
221
247
let a: U= U.G();
222
248
}
223
249
224
-
// --- fail_template_access.carbon
225
-
library "[[@TEST_NAME]]";
226
-
227
-
// TODO: Improved error: no member named `I1` in `T` of type `type`.
228
-
//
229
-
// CHECK:STDERR: fail_template_access.carbon:[[@LINE+4]]:36: error: cannot evaluate type expression [TypeExprEvaluationFailure]
@@ -273,10 +286,10 @@ fn F(T:! I(.Self) where .A = ((I(.Self) where .B = {}) where .A = {}) and .B = {
273
286
// CHECK:STDERR:
274
287
T as (I(T) where .A= (I(T) where .A= {} and .B= {}));
275
288
// CHECK:STDERR: fail_todo_nested_period_self.carbon:[[@LINE+4]]:3: error: cannot convert type `U` that implements `I(.Self) where .(I(.Self).B) = {} and .(I(.Self).A) = {}` into type implementing `I(T) where .(I(T).A) = {} and .(I(T).B) = {}` [ConversionFailureFacetToFacet]
276
-
// CHECK:STDERR: U as (I(T) where .A ={} and .B = {});
0 commit comments