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