associated_constant.carbon 547 B

123456789101112131415161718192021222324
  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. // NOAUTOUPDATE
  6. package Testcase api;
  7. interface HasName {
  8. let Name:! String;
  9. }
  10. impl i32 as HasName where .Name = "i32" {}
  11. impl String as HasName where .Name = "String" {}
  12. fn Main() -> i32 {
  13. Print(i32.(HasName.Name));
  14. Print(String.(HasName.Name));
  15. return 0;
  16. }
  17. // CHECK:STDOUT: i32
  18. // CHECK:STDOUT: String
  19. // CHECK:STDOUT: result: 0