fail_ambiguous_member.carbon 749 B

123456789101112131415161718192021222324252627
  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 A { fn F() -> i32; }
  10. interface B { fn F() -> i32; }
  11. // CHECK:STDERR: COMPILATION ERROR: {{.*}}/explorer/testdata/constraint/fail_ambiguous_member.carbon:[[@LINE+1]]: ambiguous member access, F found in interface A and interface B
  12. fn Get[T:! A & B](n: T) -> i32 { return n.F(); }
  13. impl i32 as A {
  14. fn F() -> i32 { return 1; }
  15. }
  16. impl i32 as B {
  17. fn F() -> i32 { return 2; }
  18. }
  19. fn Main() -> i32 {
  20. var z: i32 = 0;
  21. return Get(z);
  22. }