fail_ambiguous_impl_generic.carbon 796 B

12345678910111213141516171819202122232425262728
  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. class A(T:! type) {}
  10. interface B(T:! type) {}
  11. external impl forall [T:! type] A(T) as B(i32) {}
  12. external impl forall [T:! type] A(i32) as B(T) {}
  13. fn F[T:! B(i32)](x: T) {}
  14. fn G[T:! B(bool)](x: T) {}
  15. fn Main() -> i32 {
  16. let a: A(bool) = {};
  17. let b: A(i32) = {};
  18. F(a);
  19. G(b);
  20. // CHECK:STDERR: COMPILATION ERROR: {{.*}}/explorer/testdata/impl/fail_ambiguous_impl_generic.carbon:[[@LINE+1]]: ambiguous implementations of interface B(T = i32) for class A(T = i32)
  21. F(b);
  22. return 0;
  23. }