fail_compound_member_access.carbon 942 B

123456789101112131415161718192021222324252627282930
  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. // NOAUTOUPDATE
  6. package ExplorerTest api;
  7. interface MyAddWith(T:! type) {
  8. let Result:! type;
  9. fn Op[self: Self](other: T) -> Result;
  10. }
  11. constraint MyAdd {
  12. extend MyAddWith(Self) where .Result = Self;
  13. }
  14. impl i32 as MyAdd {
  15. fn Op[self: i32](other: i32) -> i32 { return self + other; }
  16. }
  17. fn Main() -> i32 {
  18. let n: i32 = 1;
  19. // TODO: This should be valid, but isn't representable in our current
  20. // MemberName value. We will likely need MemberName to remember the
  21. // constraint as written, not only the interface in which the member was
  22. // found.
  23. // CHECK:STDERR: COMPILATION ERROR: fail_compound_member_access.carbon:[[@LINE+1]]: could not find implementation of interface MyAddWith(T = Self) for i32
  24. return n.(MyAdd.Op)(n);
  25. }