member_of_value.carbon 464 B

1234567891011121314151617181920212223
  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: 2
  7. package ExplorerTest api;
  8. interface Vector {
  9. let Dim:! i32;
  10. }
  11. class Point {
  12. var x: i32;
  13. var y: i32;
  14. impl as Vector where .Dim = 2 {}
  15. }
  16. fn Main() -> i32 {
  17. var a: Point = {.x = 2, .y = 1};
  18. return a.(Vector.Dim);
  19. }