members.carbon 902 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. // NOAUTOUPDATE
  6. package ExplorerTest api;
  7. // Ensure that we can declare all different kinds of declarations as namespace
  8. // members.
  9. namespace N;
  10. __mixin N.Mixin {}
  11. base class N.BaseClass {
  12. __mix Mixin;
  13. }
  14. class N.DerivedClass {
  15. extend base: BaseClass;
  16. }
  17. namespace N.Inner;
  18. alias N.Inner.InnerClass = DerivedClass;
  19. choice N.Choice { A, B, C(DerivedClass) }
  20. interface N.Iface {
  21. fn F() -> DerivedClass*;
  22. }
  23. constraint N.Constraint {
  24. extend Iface;
  25. }
  26. var v: N.DerivedClass = {.base = {}};
  27. fn N.F[T:! Constraint]() {
  28. var v: Inner.InnerClass = {.base = {}};
  29. }
  30. impl i32 as N.Constraint {
  31. fn F() -> N.DerivedClass* { return &v; }
  32. }
  33. fn Main() -> i32 { return 0; }
  34. // CHECK:STDOUT: result: 0