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