missing_member.carbon 998 B

1234567891011121314151617181920212223242526272829
  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. // RUN: %{not} %{explorer} %s 2>&1 | \
  6. // RUN: %{FileCheck} --match-full-lines --allow-unused-prefixes=false %s
  7. // RUN: %{not} %{explorer} --parser_debug --trace_file=- %s 2>&1 | \
  8. // RUN: %{FileCheck} --match-full-lines --allow-unused-prefixes %s
  9. // AUTOUPDATE: %{explorer} %s
  10. package ExplorerTest api;
  11. interface A { fn F() -> i32; }
  12. interface B { fn G() -> i32; }
  13. // CHECK: COMPILATION ERROR: {{.*}}/explorer/testdata/constraint/missing_member.carbon:[[@LINE+1]]: member access, H not in constraint interface A & interface B where .Self:! Type is interface A and .Self:! Type is interface B
  14. fn Get[T:! A & B](n: T) -> i32 { return n.H(); }
  15. impl i32 as A {
  16. fn F() -> i32 { return 1; }
  17. }
  18. impl i32 as B {
  19. fn G() -> i32 { return 2; }
  20. }
  21. fn Main() -> i32 {
  22. var z: i32 = 0;
  23. return Get(z);
  24. }