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