members.carbon 945 B

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