fail_compound_member_access.carbon 1.0 KB

1234567891011121314151617181920212223242526272829303132
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. //
  5. // AUTOUPDATE
  6. // RUN: %{not} %{explorer-run}
  7. // RUN: %{not} %{explorer-run-trace}
  8. package ExplorerTest api;
  9. interface MyAddWith(T:! type) {
  10. let Result:! type;
  11. fn Op[self: Self](other: T) -> Result;
  12. }
  13. constraint MyAdd {
  14. extends MyAddWith(Self) where .Result = Self;
  15. }
  16. external impl i32 as MyAdd {
  17. fn Op[self: i32](other: i32) -> i32 { return self + other; }
  18. }
  19. fn Main() -> i32 {
  20. let n: i32 = 1;
  21. // TODO: This should be valid, but isn't representable in our current
  22. // MemberName value. We will likely need MemberName to remember the
  23. // constraint as written, not only the interface in which the member was
  24. // found.
  25. // CHECK:STDERR: COMPILATION ERROR: {{.*}}/explorer/testdata/named_constraint/fail_compound_member_access.carbon:[[@LINE+1]]: could not find implementation of interface MyAddWith(T = Self) for i32
  26. return n.(MyAdd.Op)(n);
  27. }