rewrite_compound_2.carbon 588 B

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