abstract_class.carbon 509 B

12345678910111213141516171819202122232425
  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 extends C {
  14. var b: i32;
  15. }
  16. fn Main() -> i32 {
  17. var d: D = { .base = {.a = 1}, .b = 2 };
  18. Print("d.a={0}", d.a);
  19. Print("d.b={0}", d.b);
  20. return 0;
  21. }