fb9a1ebda410782881e93d1375d0199654fc3671 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. // CHECK:STDOUT: 1
  7. // CHECK:STDOUT: 2
  8. // CHECK:STDOUT: 3
  9. // CHECK:STDOUT: 4
  10. // CHECK:STDOUT: 4
  11. // CHECK:STDOUT: 6
  12. // CHECK:STDOUT: 5
  13. // CHECK:STDOUT: 6
  14. // CHECK:STDOUT: result: 0
  15. package ExplorerTest api;
  16. class A(T:! type, U:! type) {}
  17. interface B(T:! type, U:! type) { fn F(); }
  18. impl forall [T:! type] A(T, i32) as B(i32, i32) {
  19. fn F() { Print("1"); }
  20. }
  21. impl forall [T:! type] A(i32, T) as B(i32, i32) {
  22. fn F() { Print("2"); }
  23. }
  24. // Intentionally out of order so that explorer can't get the right answer by
  25. // chance, by just picking the first or last matching impl.
  26. impl forall [T:! type] A(i32, i32) as B(i32, T) {
  27. fn F() { Print("4"); }
  28. }
  29. impl forall [T:! type] A(i32, i32) as B(T, i32) {
  30. fn F() { Print("3"); }
  31. }
  32. impl forall [T:! type, U:! type] A(T, i32*) as B(i32*, U) {
  33. fn F() { Print("5"); }
  34. }
  35. impl forall [T:! type, U:! type] A(i32*, T) as B(U, i32*) {
  36. fn F() { Print("6"); }
  37. }
  38. fn Main() -> i32 {
  39. A((), i32).(B(i32, i32).F)();
  40. A(i32, ()).(B(i32, i32).F)();
  41. A(i32, i32).(B((), i32).F)();
  42. A(i32, i32).(B(i32, ()).F)();
  43. A(i32, i32).(B(i32, i32).F)();
  44. A(i32*, i32*).(B(i32, i32*).F)();
  45. A(i32*, i32*).(B(i32*, i32).F)();
  46. A(i32*, i32*).(B(i32*, i32*).F)();
  47. return 0;
  48. }