use_at_compile_time.carbon 567 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. // RUN: %{explorer-run}
  7. // RUN: %{explorer-run-trace}
  8. // CHECK:STDOUT: result: 0
  9. package ExplorerTest api;
  10. interface Has(T:! type) {
  11. fn Get() -> T;
  12. }
  13. impl i32 as Has(type) {
  14. fn Get() -> type { return Self; }
  15. }
  16. class WithType(T:! Has(type)) {
  17. fn Get() -> type { return T.Get(); }
  18. }
  19. fn Main() -> i32 {
  20. var v: WithType(i32).Get() = 0;
  21. return v;
  22. }