fail_ambiguous_impl_match_first.carbon 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  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. // This match_first doesn't affect the ambiguity between
  12. // these impls and the one below.
  13. // TODO: Once we order by type structure, the second impl
  14. // in this block should win.
  15. __match_first {
  16. external impl A(i32) as B(i32) {}
  17. external impl forall [T:! type] A(i32) as B(T) {}
  18. }
  19. external impl forall [T:! type] A(T) as B(i32) {}
  20. fn F[T:! B(i32)](x: T) {}
  21. fn G[T:! B(bool)](x: T) {}
  22. fn Main() -> i32 {
  23. let a: A(bool) = {};
  24. let b: A(i32) = {};
  25. F(a);
  26. G(b);
  27. // CHECK:STDERR: COMPILATION ERROR: {{.*}}/explorer/testdata/impl/fail_ambiguous_impl_match_first.carbon:[[@LINE+1]]: ambiguous implementations of interface B(T = i32) for class A(T = i32)
  28. F(b);
  29. return 0;
  30. }