abstract_class.carbon 563 B

123456789101112131415161718192021222324252627
  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: d.a=1
  9. // CHECK:STDOUT: d.b=2
  10. // CHECK:STDOUT: result: 0
  11. package ExplorerTest api;
  12. abstract class C {
  13. var a: i32;
  14. }
  15. class D extends C {
  16. var b: i32;
  17. }
  18. fn Main() -> i32 {
  19. var d: D = { .base = {.a = 1}, .b = 2 };
  20. Print("d.a={0}", d.a);
  21. Print("d.b={0}", d.b);
  22. return 0;
  23. }