rewrite_compound_2.carbon 594 B

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