associated_constant.carbon 616 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. // RUN: %{explorer-run}
  7. // RUN: %{explorer-run-trace}
  8. // CHECK:STDOUT: i32
  9. // CHECK:STDOUT: String
  10. // CHECK:STDOUT: result: 0
  11. package Testcase api;
  12. interface HasName {
  13. let Name:! String;
  14. }
  15. external impl i32 as HasName where .Name = "i32" {}
  16. external impl String as HasName where .Name = "String" {}
  17. fn Main() -> i32 {
  18. Print(i32.(HasName.Name));
  19. Print(String.(HasName.Name));
  20. return 0;
  21. }