rewrite_compound_2.carbon 648 B

1234567891011121314151617181920212223242526272829
  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: 1
  9. package ExplorerTest api;
  10. interface HasAssoc {
  11. let Assoc:! i32;
  12. }
  13. class X {
  14. external impl as HasAssoc where .Assoc = 1 {}
  15. }
  16. alias WithoutRewrite = HasAssoc where .Assoc == 1;
  17. alias WithRewrite = HasAssoc where .Assoc = 1;
  18. fn F[T:! WithRewrite](x: T) -> i32 {
  19. return x.(WithoutRewrite.Assoc);
  20. }
  21. fn Main() -> i32 {
  22. var x: X = {};
  23. return F(x);
  24. }