non_overlapping_labels.carbon 840 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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: T as Iface
  7. // CHECK:STDOUT: T as Iface
  8. // CHECK:STDOUT: A as Iface
  9. // CHECK:STDOUT: result: 0
  10. package ExplorerTest api;
  11. interface HasType {
  12. let AssocType:! type;
  13. }
  14. interface Iface {
  15. fn F();
  16. }
  17. impl forall [T:! HasType where .Self.AssocType impls Iface] T as Iface {
  18. fn F() {
  19. Print("T as Iface");
  20. T.AssocType.(Iface.F)();
  21. }
  22. }
  23. class A {
  24. extend impl as Iface {
  25. fn F() { Print("A as Iface"); }
  26. }
  27. }
  28. class B {
  29. extend impl as HasType where .AssocType = A {}
  30. }
  31. class C {
  32. extend impl as HasType where .AssocType = B {}
  33. }
  34. fn Main() -> i32 {
  35. let c: C = {};
  36. c.(Iface.F)();
  37. return 0;
  38. }