non_overlapping_labels.carbon 841 B

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