rewrite_in_qualifier.carbon 683 B

123456789101112131415161718192021222324252627282930
  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:! type;
  9. }
  10. class X {
  11. impl as HasAssoc where .Assoc = i32 {}
  12. }
  13. alias WithoutRewrite = HasAssoc where .Assoc == i32;
  14. alias WithRewrite = HasAssoc where .Assoc = i32;
  15. fn G[T:! WithoutRewrite](x: T) -> i32 {
  16. // TODO: We should reject this once `==` isn't applied automatically.
  17. var a: T.(WithRewrite.Assoc) = 2;
  18. return a;
  19. }
  20. fn Main() -> i32 {
  21. var x: X = {};
  22. return G(x);
  23. }
  24. // CHECK:STDOUT: result: 2