abstract_class.carbon 517 B

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