rewrite_in_qualifier.carbon 743 B

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